diff --git a/README.markdown b/README.markdown
index 4698f85..960189b 100644
--- a/README.markdown
+++ b/README.markdown
@@ -39,6 +39,14 @@ Options
targetHeight | integer | 180 | no |
Height in pixels of the cropping window |
+
+ startX | integer | null | no |
+ Set start image position on X axis. |
+
+
+ startY | integer | null | no |
+ Set start image position on Y axis. |
+
onChange | function | function(){} | no |
Callback function that gets called whenever the values change. cropX, cropY, cropW, cropH, mustStretch (boolean) values are passed to this function in a hash. Use the this keyword in the function for a reference to the element that was updated. |
diff --git a/jquery.jWindowCrop.js b/jquery.jWindowCrop.js
index a2f85d4..0953451 100644
--- a/jquery.jWindowCrop.js
+++ b/jquery.jWindowCrop.js
@@ -82,6 +82,9 @@
base.setZoom(base.workingPercent-zoomIncrement);
return false;
};
+ base.setFocus = function (x, y) {
+ base.$image.css({'left' : (x*-1*base.workingPercent.toString()+'px'), 'top' : (y*-1*base.workingPercent.toString()+'px')});
+ };
function initializeDimensions() {
if(base.originalWidth == 0) {
@@ -108,9 +111,13 @@
base.focalPoint = {'x': Math.round(x), 'y': Math.round(y)};
}
function focusOnCenter() {
- var left = fillContainer((Math.round((base.focalPoint.x*base.workingPercent) - base.options.targetWidth/2)*-1), base.$image.width(), base.options.targetWidth);
- var top = fillContainer((Math.round((base.focalPoint.y*base.workingPercent) - base.options.targetHeight/2)*-1), base.$image.height(), base.options.targetHeight);
- base.$image.css({'left': (left.toString()+'px'), 'top': (top.toString()+'px')})
+ if ( typeof base.options.startX != null && typeof base.options.startY != null ) {
+ base.setFocus( base.options.startX, base.options.startY );
+ } else {
+ var left = fillContainer((Math.round((base.focalPoint.x*base.workingPercent) - base.options.targetWidth/2)*-1), base.$image.width(), base.options.targetWidth);
+ var top = fillContainer((Math.round((base.focalPoint.y*base.workingPercent) - base.options.targetHeight/2)*-1), base.$image.height(), base.options.targetHeight);
+ base.$image.css({'left': (left.toString()+'px'), 'top': (top.toString()+'px')});
+ }
storeFocalPoint();
}
function updateResult() {