Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
_updateCenterPoint.call(self);
_updateZoomLimits.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");
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ <h3>Methods</h3>
</li>
</ul>
</li>
<li id="setViewPort">
<strong class="focus">setViewPort(width, height)</strong><em></em>
<p>Set the viewport of a Croppie instance. The width and height are the new values set to the viewport.</p>
<ul class="parameter-list">
<li>
<code class="language-javascript">width</code> the new width for the viewport.
</li>
<li>
<code class="language-javascript">height</code> the new height for the viewport.
</li>
</ul>
</li>
</ul>
</section>
<section>
Expand Down