Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initialLeft / Top to set initial crop region #266

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update croppic.js
Fixing the removed crop button in your versiin... Also allowing the user to set a precropped image to load at init
  • Loading branch information
angekouf authored May 30, 2017
commit 4420be088ffeeb4379647085d74d2888bc0a20b7
24 changes: 15 additions & 9 deletions croppic.js
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@
scaleToFill: true,
processInline: false,
loadPicture:'',
loadCroppedPicture:'',
onReset: null,
enableMousescroll: false,

@@ -103,6 +104,7 @@
that.actualRotation = 0;

if( jQuery.isEmptyObject(that.defaultImg)){ that.defaultImg = that.obj.find('img'); }
if( !jQuery.isEmptyObject(that.options.loadCroppedPicture)){ that.loadCroppedImg(that.options.loadCroppedPicture) }

that.createImgUploadControls();

@@ -278,6 +280,7 @@

}else{
that.cropControlRemoveCroppedImage.on('click',function(){
that.options.loadCroppedPicture = '';
that.croppedImg.remove();
jQuery(this).hide();

@@ -406,8 +409,8 @@
var cropControlZoomOut = '<i class="cropControlZoomOut"></i>';
var cropControlZoomMuchOut = '';
var cropControlRotateLeft = '';
var cropControlRotateRight = '';
var cropControlCrop = '';
var cropControlRotateRight = '';
var cropControlCrop = '<i class="cropControlCrop"></i>';
var cropControlReset = '<i class="cropControlReset"></i>';

var html;
@@ -692,6 +695,14 @@
}

//
},
loadCroppedImg: function (croppedUrl) {
var that = this;

that.obj.append('<img class="croppedImg" src="' + croppedUrl + '">');
if (that.options.outputUrlId !== '') { jQuery('#' + that.options.outputUrlId).val(croppedUrl); }

that.croppedImg = that.obj.find('.croppedImg');
},
afterCrop: function (data) {
var that = this;
@@ -708,12 +719,7 @@
that.imgEyecandy.hide();

that.destroy();

that.obj.append('<img class="croppedImg" src="' + response.url + '">');
if (that.options.outputUrlId !== '') { jQuery('#' + that.options.outputUrlId).val(response.url); }

that.croppedImg = that.obj.find('.croppedImg');

that.loadCroppedImg(response.url);
that.init();

that.hideLoader();
@@ -869,4 +875,4 @@
}

};
})(window, document);
})(window, document);