Skip to content

Commit

Permalink
Add adaptation of the stencil to changes of props (stencilProps, maxW…
Browse files Browse the repository at this point in the history
…idth, maxHeight and etc.)
  • Loading branch information
Norserium committed Dec 5, 2019
1 parent 5ff84d8 commit 01fe4f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-advanced-cropper",
"version": "0.14.0",
"version": "0.14.1",
"description": "The advanced library to create your own croppers suited for any website design",
"author": "Norserium",
"license": "MIT",
Expand Down
17 changes: 13 additions & 4 deletions src/Cropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,23 @@ export default {
this.onChangeImage();
},
minWidth() {
this.resetCoordinates();
this.onPropsChange();
},
maxWidth() {
this.resetCoordinates();
this.onPropsChange();
},
minHeight() {
this.resetCoordinates();
this.onPropsChange();
},
maxHeight() {
this.resetCoordinates();
this.onPropsChange();
},
stencilProps(oldProps, newProps) {
const significantProps = ['aspectRatio', 'minAspectRatio', 'maxAspectRatio'];
if (significantProps.find(prop => oldProps[prop] !== newProps[prop])) {
Vue.nextTick(this.onPropsChange);
}
}
},
mounted() {
this.debouncedUpdate = debounce(
Expand Down Expand Up @@ -558,6 +564,9 @@ export default {
this.applyTransforms(transforms, autoZoom);
});
},
onPropsChange() {
this.applyTransforms(this.coordinates, true);
},
applyTransforms(transforms, autoZoom = false) {
const aspectRatio = this.stencilAspectRatios();
const allowedArea = {
Expand Down

0 comments on commit 01fe4f2

Please sign in to comment.