Commit 69cab8a4 authored by Miłosz Sobczak's avatar Miłosz Sobczak
Browse files

detetcing in change crop is made by user or not

Showing with 59 additions and 49 deletions
+59 -49
{
"name": "image-mask-cropper",
"version": "1.4.6",
"version": "1.4.7",
"homepage": "http://gl.pixers.pl:8080/milosz.sobczak/image-mask-cropper/tree/master",
"authors": [
"milosz.sobczak@pixers.pl"
......
......@@ -83,6 +83,7 @@
this.cropZone = Object.create(elementObject);
this.isRunning = false;
this._isUser = false;
this._init()
return this;
......@@ -248,9 +249,7 @@
}
}
this.options.onMoveCrop({
coords: this.getCropPosition()
});
this._triggerMoveFunc();
},
/**
* Setter.
......@@ -300,6 +299,20 @@
this.options.enableCrop = false;
this._updateContainerClass();
},
/**
* Triggers callback func when crop is moved.
* @return {void}
*/
_triggerMoveFunc: function () {
var self = this;
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition(),
isUser: self._isUser
});
}
},
/**
* Refresh whole scene based on configuration.
* @return {void}
......@@ -316,6 +329,8 @@
}
};
this._isUser = false;
if (this._isContainerExistingInDom() === false) {
this._createContainerDOMElement();
}
......@@ -383,11 +398,7 @@
this.element.$element.on('imageMaskCropper:moveCurrentCrop', function (e, diffPercentCoords) {
self.setPositionCoords(diffPercentCoords);
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
self._triggerMoveFunc();
});
},
/**
......@@ -501,6 +512,8 @@
* @return {void}
*/
_moveCropZoneOrImage: function (startPosCSS, diff) {
this._isUser = true;
if (this.isRunning === true) {
throw new Error('Plugin is still running. Can\'t move.');
}
......@@ -527,11 +540,8 @@
countedValue = this._getLeftPercentOfContainer(startPosCSS.left - diffCoords.x);
this._setPositionLeftOfImageMain(countedValue);
}
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
this._triggerMoveFunc();
},
/**
* Moves crop above imageMain.
......@@ -546,11 +556,7 @@
this._setPositionCoordsY(this._getTopPercentOfContainer(startPosCSS.top - diffCoords.y));
this._setPositionOfCropZone();
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
this._triggerMoveFunc();
},
/**
* Gets percent of container's height.
......@@ -1135,8 +1141,7 @@
return result;
})(), options);
window.maskCropperInstance = self.maskCropperInstance = new imageMaskCropper(settings, self);
self.maskCropperInstance = new imageMaskCropper(settings, self);
return this.maskCropperInstance;
};
/**
......@@ -1155,8 +1160,8 @@
maskOptions: {
left: 0,
top: 0,
width: 80,
height: 80
width: 100,
height: 100
},
/**
* Initial coords.
......@@ -1164,7 +1169,7 @@
*/
positionCoords: {
x: 0,
y: 20
y: 0
},
enableCrop: true,
maxContainerMargin: false,
......
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.6",
"version": "1.4.7",
"author": "Miłosz Sobczak <milosz.sobczak@pixers.pl>",
"devDependencies": {
"gulp": "3.9.0",
......
......@@ -83,6 +83,7 @@
this.cropZone = Object.create(elementObject);
this.isRunning = false;
this._isUser = false;
this._init()
return this;
......@@ -248,9 +249,7 @@
}
}
this.options.onMoveCrop({
coords: this.getCropPosition()
});
this._triggerMoveFunc();
},
/**
* Setter.
......@@ -300,6 +299,20 @@
this.options.enableCrop = false;
this._updateContainerClass();
},
/**
* Triggers callback func when crop is moved.
* @return {void}
*/
_triggerMoveFunc: function () {
var self = this;
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition(),
isUser: self._isUser
});
}
},
/**
* Refresh whole scene based on configuration.
* @return {void}
......@@ -316,6 +329,8 @@
}
};
this._isUser = false;
if (this._isContainerExistingInDom() === false) {
this._createContainerDOMElement();
}
......@@ -383,11 +398,7 @@
this.element.$element.on('imageMaskCropper:moveCurrentCrop', function (e, diffPercentCoords) {
self.setPositionCoords(diffPercentCoords);
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
self._triggerMoveFunc();
});
},
/**
......@@ -501,6 +512,8 @@
* @return {void}
*/
_moveCropZoneOrImage: function (startPosCSS, diff) {
this._isUser = true;
if (this.isRunning === true) {
throw new Error('Plugin is still running. Can\'t move.');
}
......@@ -527,11 +540,8 @@
countedValue = this._getLeftPercentOfContainer(startPosCSS.left - diffCoords.x);
this._setPositionLeftOfImageMain(countedValue);
}
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
this._triggerMoveFunc();
},
/**
* Moves crop above imageMain.
......@@ -546,11 +556,7 @@
this._setPositionCoordsY(this._getTopPercentOfContainer(startPosCSS.top - diffCoords.y));
this._setPositionOfCropZone();
if (typeof self.options.onMoveCrop === 'function') {
self.options.onMoveCrop.call(self, {
coords: self.getCropPosition()
});
}
this._triggerMoveFunc();
},
/**
* Gets percent of container's height.
......@@ -1135,8 +1141,7 @@
return result;
})(), options);
window.maskCropperInstance = self.maskCropperInstance = new imageMaskCropper(settings, self);
self.maskCropperInstance = new imageMaskCropper(settings, self);
return this.maskCropperInstance;
};
/**
......@@ -1155,8 +1160,8 @@
maskOptions: {
left: 0,
top: 0,
width: 80,
height: 80
width: 100,
height: 100
},
/**
* Initial coords.
......@@ -1164,7 +1169,7 @@
*/
positionCoords: {
x: 0,
y: 20
y: 0
},
enableCrop: true,
maxContainerMargin: false,
......
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