Fix image zoom
This commit is contained in:
@@ -264,17 +264,16 @@
|
||||
this.$nav.mousewheel((e) => {
|
||||
var asImg = self.album[this.currentImageIndex];
|
||||
if(!asImg.type != 'video') {
|
||||
asTransform = this.$image.css('transform').replace(/[^0-9\-.,]/g, '').split(',');
|
||||
var fOldZoom = parseFloat(asTransform[0] || 1);
|
||||
var fOldTranslateX = parseFloat(asTransform[4] || 0);
|
||||
var fOldTranslateY = parseFloat(asTransform[5] || 0);
|
||||
var fOldZoom = parseFloat(asTransform[0] || 1);
|
||||
var fNewZoom = Math.min(Math.max(fOldZoom + e.deltaY / 10, 1), Math.max(asImg.width/this.$image.width(), asImg.height/this.$image.height()));
|
||||
let asTransform = this.$image.css('transform').replace(/[^0-9\-.,]/g, '').split(',');
|
||||
let fOldZoom = parseFloat(asTransform[0] || 1);
|
||||
let fOldTranslateX = parseFloat(asTransform[4] || 0);
|
||||
let fOldTranslateY = parseFloat(asTransform[5] || 0);
|
||||
let fNewZoom = Math.min(Math.max(fOldZoom + e.deltaY / 10, 1), Math.max(asImg.width/this.$image.width(), asImg.height/this.$image.height()));
|
||||
|
||||
var fTransX = fOldTranslateX + (fNewZoom - fOldZoom) * (this.$image.width()/2 - e.offsetX);
|
||||
var fTransY = fOldTranslateY + (fNewZoom - fOldZoom) * (this.$image.height()/2 - e.offsetY);
|
||||
var fTransMaxX = (fNewZoom - 1) * this.$image.width() / 2;
|
||||
var fTransMaxY = (fNewZoom - 1) * this.$image.height() / 2;
|
||||
let fTransX = fOldTranslateX + (fNewZoom - fOldZoom) * (this.$image.width()/2 - e.offsetX);
|
||||
let fTransY = fOldTranslateY + (fNewZoom - fOldZoom) * (this.$image.height()/2 - e.offsetY);
|
||||
let fTransMaxX = (fNewZoom - 1) * this.$image.width() / 2;
|
||||
let fTransMaxY = (fNewZoom - 1) * this.$image.height() / 2;
|
||||
|
||||
fTransX = Math.max(Math.min(fTransX, fTransMaxX), fTransMaxX * -1);
|
||||
fTransY = Math.max(Math.min(fTransY, fTransMaxY), fTransMaxY * -1);
|
||||
|
||||
Reference in New Issue
Block a user