Commit 4cf3eabe authored by Dayton Johnson's avatar Dayton Johnson

MTC-1252: Adding check for cropper initialization before cropper object is accessed

parent b3764b19
......@@ -343,7 +343,8 @@ module.exports={
var titleBar = $cropDialog.titleBar("Select Image");
var aspectDropId = "aspect-dropdown-" + modalId;
var aspectOptions=makeDropdown(aspectDropId, _.map(availableCroppings, (crop)=>{if(crop){return{title:crop.title, value:crop.aspect}}} ));
var revealFocalPoint=function(){window.alert("Can't reveal focal point")};
var revealFocalPoint = function () { window.alert("Can't reveal focal point") };
var isImageCropperInitialized = false;
var body=`
<div class="row" style="margin-top:.5rem;margin-bottom:.5rem;">
......@@ -427,14 +428,15 @@ module.exports={
writeResults();
$cropDialog.closeModal();
})
$slider.on("input",function(){
var pct=$slider.val();
var zoom = (pct * (highestRatio-lowestRatio) / 100) + lowestRatio;
$image.cropper("zoomTo", zoom);
var cropData = $image.cropper("getData");
setCropSize(cropData.width, cropData.height);
var zoom = (pct * (highestRatio - lowestRatio) / 100) + lowestRatio;
if (isImageCropperInitialized) {
$image.cropper("zoomTo", zoom);
var cropData = $image.cropper("getData");
setCropSize(cropData.width, cropData.height);
}
})
$image.cropper({
......@@ -451,6 +453,7 @@ module.exports={
minCropBoxHeight: minHeight,
ready: function () {
isImageCropperInitialized = true;
$cropDialog.find(".set-focus").click(function(){
revealFocalPoint();
......
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