Created
June 27, 2019 11:57
-
-
Save williammustaffa/c68137762359bac7e9196a9b02be9471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PinchZoom.prototype.getContainerCenter = function () { | |
var centerX = this.container.offsetLeft + this.container.offsetWidth / 2; | |
var centerY = this.container.offsetTop + this.container.offsetHeight / 2; | |
return { | |
x: centerX, | |
y: centerY, | |
}; | |
}; | |
PinchZoom.prototype.zoomTo = function (zoomFactor) { | |
var center = this.getContainerCenter(); | |
var startZoomFactor = this.zoomFactor; | |
var updateProgress = (function (progress) { | |
this.scaleTo(startZoomFactor + progress * (zoomFactor - startZoomFactor), center); | |
}).bind(this); | |
this.animate(this.options.animationDuration, updateProgress, this.swing); | |
}; | |
PinchZoom.prototype.zoomIn = function () { | |
this.zoomTo(2); | |
}; | |
PinchZoom.prototype.zoomOut = function () { | |
// Reset Zoom | |
this.zoomOutAnimation(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment