Commit 69353a5f authored by Miłosz Sobczak's avatar Miłosz Sobczak
Browse files

changes way of changing mask options

Showing with 43 additions and 25 deletions
+43 -25
{
"name": "image-mask-cropper",
"version": "1.4.9",
"version": "1.5.0",
"homepage": "http://gl.pixers.pl:8080/milosz.sobczak/image-mask-cropper/tree/master",
"authors": [
"milosz.sobczak@pixers.pl"
......
......@@ -177,7 +177,7 @@
return false;
}
this.options.maskOptions = $.extend(true, this.options.maskOptions, maskOptions);
this._init();
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Gets coordinatates of crop.
......@@ -258,11 +258,8 @@
* @return {void}
*/
setMaskOptionsHeight: function (height) {
var yDiff = Math.max((this.options.positionCoords.y + this._setMaskOptionsHeight(height)) - 100, 0);
this.setPositionCoords({
y: this.options.positionCoords.y + yDiff
});
this._setMaskOptionsHeight(height);
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Setter.
......@@ -271,11 +268,8 @@
* @return {void}
*/
setMaskOptionsWidth: function (width) {
var xDiff = Math.max((this.options.positionCoords.x + this._setMaskOptionsWidth(width)) - 100, 0);
this.setPositionCoords({
x: this.options.positionCoords.x + xDiff
});
this._setMaskOptionsWidth(width)
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Enables crop plugin option.
......@@ -299,6 +293,21 @@
this.options.enableCrop = false;
this._updateContainerClass();
},
/**
* Gets valid position coords based on mask options.
*
* @param {object} maskOptions
* @return {object} crop positions
*/
_getPositionCoordsValid: function (maskOptions) {
var xDiff = Math.max((this.options.positionCoords.x + maskOptions.width) - 100, 0),
yDiff = Math.max((this.options.positionCoords.y + maskOptions.height) - 100, 0);
return {
x: this.options.positionCoords.x + xDiff,
y: this.options.positionCoords.y + yDiff
};
},
/**
* Triggers callback func when crop is moved.
* @return {void}
......
This diff is collapsed.
{
"name": "image-mask-cropper",
"description": "Jquery library that gives you ability to move images across container using mask as well",
"version": "1.4.9",
"version": "1.5.0",
"author": "Miłosz Sobczak <milosz.sobczak@pixers.pl>",
"devDependencies": {
"gulp": "3.9.0",
......
......@@ -177,7 +177,7 @@
return false;
}
this.options.maskOptions = $.extend(true, this.options.maskOptions, maskOptions);
this._init();
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Gets coordinatates of crop.
......@@ -258,11 +258,8 @@
* @return {void}
*/
setMaskOptionsHeight: function (height) {
var yDiff = Math.max((this.options.positionCoords.y + this._setMaskOptionsHeight(height)) - 100, 0);
this.setPositionCoords({
y: this.options.positionCoords.y + yDiff
});
this._setMaskOptionsHeight(height);
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Setter.
......@@ -271,11 +268,8 @@
* @return {void}
*/
setMaskOptionsWidth: function (width) {
var xDiff = Math.max((this.options.positionCoords.x + this._setMaskOptionsWidth(width)) - 100, 0);
this.setPositionCoords({
x: this.options.positionCoords.x + xDiff
});
this._setMaskOptionsWidth(width)
this.setPositionCoords(this._getPositionCoordsValid(this.options.maskOptions));
},
/**
* Enables crop plugin option.
......@@ -299,6 +293,21 @@
this.options.enableCrop = false;
this._updateContainerClass();
},
/**
* Gets valid position coords based on mask options.
*
* @param {object} maskOptions
* @return {object} crop positions
*/
_getPositionCoordsValid: function (maskOptions) {
var xDiff = Math.max((this.options.positionCoords.x + maskOptions.width) - 100, 0),
yDiff = Math.max((this.options.positionCoords.y + maskOptions.height) - 100, 0);
return {
x: this.options.positionCoords.x + xDiff,
y: this.options.positionCoords.y + yDiff
};
},
/**
* Triggers callback func when crop is moved.
* @return {void}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment