pinchzoom icon indicating copy to clipboard operation
pinchzoom copied to clipboard

Stop from scaling on initialization

Open DmitryS1990 opened this issue 5 years ago • 2 comments

Hello. Is there an option to prevent scaling on initialization? Or if not, where to look to see scale on init code. Thank you.

DmitryS1990 avatar May 02 '19 00:05 DmitryS1990

https://github.com/manuelstofer/pinchzoom/blob/master/src/pinch-zoom.js#L89 var PinchZoom = function (el, options) { this.el = el; this.zoomFactor = initScaleRate; // your initScaleRate value

jinghaonode avatar Jun 21 '19 01:06 jinghaonode

It works for me. But you might need to change a little bit of code from the pinch-zoom.js by yourself.

in pinch-zoom.js:87

var PinchZoom = function PinchZoom(el, options) {
    // ...
    this.options = Object.assign({}, this.defaults, options);
    // Add this line of code below
    // Which makes default zoomFactor been available to be change by options
    this.zoomFactor = this.options.zoomFactor ? this.options.zoomFactor : 1;
    // ...
})

in your JavaScript file:

new PinchZoom.default(el, {
    // Pass initialize scale rate
    zoomFactor: 5
    // Add any other options you need
    // ...
})

andy19910102 avatar Nov 18 '19 08:11 andy19910102