return;
}
- var diffx = this.fluidbook.resize.ww * (this.fluidbook.zoom.zoom - 1);
- var diffy = this.fluidbook.resize.hh * (this.fluidbook.zoom.zoom - 1);
-
- var currentX = this.fluidbook.zoom.origin[0] * diffx;
- var currentY = this.fluidbook.zoom.origin[1] * diffy;
+ var currentX = this.fluidbook.zoom.originpx[0];
+ var currentY = this.fluidbook.zoom.originpx[1];
var x = currentX - e.dx;
var y = currentY - e.dy;
- x /= diffx;
- y /= diffy;
-
this.fluidbook.zoom.setOrigin(x, y, true, inertia);
return false;
var ox = (cx - zrect.left) / z;
var oy = (cy - zrect.top) / z;
- ox = ox / this.fluidbook.resize.ww;
- oy = oy / this.fluidbook.resize.hh;
-
- // touch pos in % of screen
- var tx = cx / this.fluidbook.resize.ww;
- var ty = cy / this.fluidbook.resize.hh;
-
this.fluidbook.zoom.setOrigin(ox, oy, true);
},
};
function FluidbookZoom(fluidbook) {
this.fluidbook = fluidbook;
this.zoom = 0;
- this.origin = ['0%', '0%'];
+ this.originpct = ['0%', '0%'];
+ this.originpx = ['0px', '0px'];
this.max = this.fluidbook.datas.zoomw / 100;
this.transition = true;
this.hideInterfaceTimeout;
this.setZoom(1, -1);
},
- setOrigin: function (x, y, force, inertia) {
+ setOriginPct: function (x, y, force, inertia) {
if (force == undefined) {
force = false;
}
}
x = Math.min(1, Math.max(0, x));
y = Math.min(1, Math.max(0, y));
- this.origin = [x, y];
+ this.originpct = [x, y];
if (!force && this.fluidbook.zoom.zoom == 1) {
return;
} else {
$("#z").removeClass('transition-inertia');
}
$("#z").transform({
- origin: [this.origin[0] * 100 + '%', this.origin[1] * 100 + '%']
+ origin: [this.originpct[0] * 100 + '%', this.originpct[1] * 100 + '%']
+ }, {
+ preserve: true
+ });
+ }
+ },
+
+ setOrigin: function (x, y, force, inertia) {
+ if (force == undefined) {
+ force = false;
+ }
+ if (inertia == undefined) {
+ inertia = false;
+ }
+ x = Math.max(0, Math.min(x, this.fluidbook.resize.ww));
+ y = Math.max(0, Math.min(y, this.fluidbook.resize.hh));
+
+ this.originpx = [x, y];
+ if (!force && this.fluidbook.zoom.zoom == 1) {
+ return;
+ } else {
+ if (inertia) {
+ $("#z").addClass('transition-inertia');
+ } else {
+ $("#z").removeClass('transition-inertia');
+ }
+ $("#z").transform({
+ origin: [this.originpx[0] + 'px', this.originpx[1] + 'px']
}, {
preserve: true
});
if (this.desktopScale == 1) {
animation.origin = ['50%', '50%'];
- } else {
- animation.origin = [this.origin[0] * 100 + '%', this.origin[1] * 100 + '%'];
}
var hiddenElements = $("header,footer,#interface");
clearTimeout(this.hideInterfaceTimeout);
$(hiddenElements).show().removeClass('hidden');
}
- $("#z").transform(animation);
+ $("#z").transform(animation, {preserve: true});
$this.triggerEvent(((this.zoom == 1) ? 'out' : 'in') + '.start');
if (!this.transition) {