From 472efc0093c26d30422ac41d28b15bb2e2ed82a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Kr=C3=A4mer?= Date: Mon, 1 Jul 2019 13:40:19 +0200 Subject: [PATCH 1/3] added function to set viewport after croppie was instantiated --- croppie.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/croppie.js b/croppie.js index 2652d0ef..68c8f0a3 100755 --- a/croppie.js +++ b/croppie.js @@ -1538,6 +1538,26 @@ }; } + /** Update viewport to new dimensions + * @param w int new width in px + * @param h int new height in px + */ + function _setViewport(w, h) { + var self = this; + + self.options.viewport.height = h; + self.options.viewport.width = w; + css(self.elements.viewport, { + height: self.options.viewport.height + 'px', + width: self.options.viewport.width + 'px' + }); + + _updateOverlay.call(self); + _updateZoomLimits.call(self); + _updateCenterPoint.call(self); + _triggerUpdate.call(self); + } + function Croppie(element, opts) { if (element.className.indexOf('croppie-container') > -1) { throw new Error("Croppie: Can't initialize croppie more than once"); @@ -1630,6 +1650,10 @@ }, destroy: function () { return _destroy.call(this); + }, + /** update viewport to new dimensions */ + setViewport: function (widthVP, heightVP) { + _setViewport.call(this, widthVP, heightVP); } }); return Croppie; From 1f6770dfccbfb5ee779d38c4c1ec150e3439cf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Kr=C3=A4mer?= Date: Mon, 1 Jul 2019 14:12:44 +0200 Subject: [PATCH 2/3] added documentation --- index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.html b/index.html index 928a04b5..3cf46eb9 100644 --- a/index.html +++ b/index.html @@ -278,6 +278,18 @@

Methods

+
  • + setViewPort(width, height) +

    Set the viewport of a Croppie instance. The width and height are the new values set to the viewport.

    +
      +
    • + width the new width for the viewport. +
    • +
    • + height the new height for the viewport. +
    • +
    +
  • From 513fadccf7998d6a229c2d1e73f68ee5e5d8010f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Kr=C3=A4mer?= Date: Tue, 2 Jul 2019 16:08:18 +0200 Subject: [PATCH 3/3] Fix resulting image, if centerpoint and zoom not called in the correct order (?) --- croppie.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/croppie.js b/croppie.js index 68c8f0a3..9c0563b1 100755 --- a/croppie.js +++ b/croppie.js @@ -1553,8 +1553,8 @@ }); _updateOverlay.call(self); - _updateZoomLimits.call(self); _updateCenterPoint.call(self); + _updateZoomLimits.call(self); _triggerUpdate.call(self); }