Skip to content

Commit

Permalink
Merge pull request #151 from collective/mle-make-minimal-size-work-again
Browse files Browse the repository at this point in the history
Adapt limit_minimum_cropping_size to work with current cropperjs version
  • Loading branch information
maethu authored Oct 18, 2023
2 parents d47d5f5 + 07ab689 commit 1ee4d17
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ include *.js
include *.json
include *.lock
include *.txt
include *.yaml
15 changes: 15 additions & 0 deletions instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# This is a cookiecutter configuration context file for
#
# cookiecutter-zope-instance
#
# available options are documented at
# https://github.com/bluedynamics/cookiecutter-zope-instance/
#
# read also README_MAKE.md in this folder
#
default_context:
wsgi_http_listen: localhost:8080
initial_user_name: admin
initial_user_password: admin
db_storage: direct
2 changes: 2 additions & 0 deletions news/150.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix minimal crop size implementation, to support current cropperjs version.
[maethu]
28 changes: 19 additions & 9 deletions resources/js/cropperpattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,35 @@ export default Base.extend({
limit_minimum_cropping_size: function () {
var current = this.cropper,
newbox = {};
const relativeWidth =
(current.canvasData.width /
current.canvasData.naturalWidth) *
this.options.target_width;
const relativeHeight =
(current.canvasData.height /
current.canvasData.naturalHeight) *
this.options.target_height;

if (
current.width < this.options.target_width ||
current.height < this.options.target_height
current.cropBoxData.width <= Math.round(relativeWidth) ||
current.cropBoxData.height <= Math.round(relativeHeight)
) {
newbox.width = this.options.target_width;
newbox.height = this.options.target_height;
if (current.x + this.options.target_width > this.options.true_width) {
const data = current.getData()
if (data.x + this.options.target_width > this.options.true_width) {
newbox.x = this.options.true_width - this.options.target_width;
} else {
newbox.x = current.x;
newbox.x = data.x;
}
if (current.y + this.options.target_height > this.options.true_height) {
if (data.y + this.options.target_height > this.options.true_height) {
newbox.y = this.options.true_height - this.options.target_height;
} else {
newbox.y = current.y;
newbox.y = data.y;
}
newbox.rotate = current.rotate;
newbox.scaleX = current.scaleX;
newbox.scaleY = current.scaleY;
newbox.rotate = data.rotate;
newbox.scaleX = data.scaleX;
newbox.scaleY = data.scaleY;
this.while_reset = true;
this.cropper.setData(newbox);
this.while_reset = false;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit 1ee4d17

Please sign in to comment.