this.fluidbook = fluidbook;
this.scale = 1;
this.refScale = 1;
+ this.maxScale = 1;
+ this.initialImageWidth = 0;
+ this.initialImageHeight = 0;
+ this.currentImageWidth = 0;
+ this.currentImageHeight = 0;
this.element;
this.image;
this.mouseX;
},
normalizeScale: function (s) {
- return Math.max(1, Math.min(3.5, s));
+ return Math.max(1, Math.min(this.maxScale, s));
},
openZoomhd: function (p1, p2, callback) {
view += '<div class="content h100"><div class="zoomhdHolder"><div class="zoomhdMove"><div class="zoomhdRefScale"><div class="zoomhdScale"><div class="zoomhdImage"></div>';
view += '</div></div></div><div class="zoomhdControls"><a href="#" class="minus">' + getSpriteIcon('interface-minus') + '</a><a href="#" class="plus">' + getSpriteIcon('interface-plus') + '</a></div></div></div>';
- this.fluidbook.menu.viewWrap(view,'zoomhd','data-fullscreen="1" dir="ltr"','h100');
+ this.fluidbook.menu.viewWrap(view, 'zoomhd', 'data-fullscreen="1" dir="ltr"', 'h100');
this.element = $("#view").find('.zoomhdScale');
this.image = fluidbook.loader.loadImage('data/links/' + link.to, null, null, null, null, function () {
top: this.image.naturalHeight / -2
}
);
- this.resize();
+ resize();
},
updateMovePosPct: function () {
return;
}
- var irect = this.element.find('.zoomhdImage').get(0).getBoundingClientRect();
- this.dragMaxX = 60 + Math.abs(this.fluidbook.resize.ww - irect.width) / 2;
+ this.dragMaxX = Math.abs(this.initialImageWidth - this.currentImageWidth) / 2;
this.dragMinX = -this.dragMaxX;
- this.dragMaxY = 60 + Math.abs(this.fluidbook.resize.hh - irect.height) / 2;
+ this.dragMaxY = Math.abs(this.initialImageHeight - this.currentImageHeight) / 2;
this.dragMinY = -this.dragMaxY;
},
resize: function () {
-
- var ww = this.fluidbook.resize.ww;
- var hh = this.fluidbook.resize.hh;
-
- this.aw = ww - 60;
- this.ah = hh - 110;
-
- this.refScale = Math.min(this.aw / this.image.naturalWidth, this.ah / this.image.naturalHeight);
-
this.element.closest('.zoomhdRefScale').css({transform: 'scale(' + this.refScale + ')'});
this.element.css({transform: 'scale(' + this.scale + ')'});
+ this.currentImageWidth = this.initialImageWidth * this.scale;
+ this.currentImageHeight = this.initialImageHeight * this.scale;
this.updateMovePosPct();
},
+
+ setAvailableDimensions: function (aw, ah) {
+ this.aw = aw;
+ this.ah = ah;
+ this.refScale = Math.min(this.aw / this.image.naturalWidth, this.ah / this.image.naturalHeight);
+ this.maxScale = 1 / this.refScale;
+ this.initialImageWidth = this.image.naturalWidth * this.refScale;
+ this.initialImageHeight = this.image.naturalHeight * this.refScale;
+ },
+
+ getContainerDimensions: function () {
+ return {width: this.initialImageWidth, height: this.initialImageHeight};
+ },
}
$(function () {