Skip to content

Commit

Permalink
Merge pull request #3 from eliksir/stian/show-resize-info
Browse files Browse the repository at this point in the history
Always show the resize info box
  • Loading branch information
stianpr authored Jan 13, 2022
2 parents 4a0d071 + 5bed7df commit beb0073
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@
var vr;
var hr;

function updateResizeInfo() {
if (!sizeInfo) return;

sizeInfo.innerHTML = (
fix(self.options.viewport.width) +
'×' +
fix(self.options.viewport.height)
);
};

addClass(wrap, 'cr-resizer');
css(wrap, {
width: this.options.viewport.width + 'px',
Expand All @@ -484,10 +494,8 @@
if (this.options.resizeControls.sizeInfo) {
sizeInfo = document.createElement('span');
addClass(sizeInfo, 'cr-resizer-info');
css(sizeInfo, {
display: 'none',
});
wrap.appendChild(sizeInfo);
updateResizeInfo();
}

if (this.options.resizeControls.height) {
Expand Down Expand Up @@ -544,17 +552,6 @@
originalY = touches.pageY;
}

if (sizeInfo) {
sizeInfo.innerHTML = (
fix(self.options.viewport.width) +
'×' +
fix(self.options.viewport.height)
);
css(sizeInfo, {
display: 'block',
});
}

window.addEventListener('mousemove', mouseMove);
window.addEventListener('touchmove', mouseMove);
window.addEventListener('mouseup', mouseUp);
Expand Down Expand Up @@ -610,31 +607,19 @@
});
}

if (sizeInfo) {
sizeInfo.innerHTML = (
fix(self.options.viewport.width) +
'×' +
fix(self.options.viewport.height)
);
}

_updateOverlay.call(self);
_updateZoomLimits.call(self);
_updateCenterPoint.call(self);
_triggerUpdate.call(self);
originalY = pageY;
originalX = pageX;

updateResizeInfo();
}

function mouseUp() {
isDragging = false;

if (sizeInfo) {
css(sizeInfo, {
display: 'none',
});
}

window.removeEventListener('mousemove', mouseMove);
window.removeEventListener('touchmove', mouseMove);
window.removeEventListener('mouseup', mouseUp);
Expand Down

0 comments on commit beb0073

Please sign in to comment.