this.prepareTexture(turning.flip[1], function (t1) {
$this.prepareTexture(turning.flip[0], function (t2) {
- $this.texturesLoaded(t1, t2, callback);
+ $this.texturesLoaded(t1, t2, turning.dir, callback);
});
})
},
}
},
- texturesLoaded: function (t1, t2, callback) {
+ texturesLoaded: function (t1, t2, dir, callback) {
if (this.textures === undefined || this.textures === null || this.textures.length === 0) {
// If textures are not loaded
console.warn('Texture object not ready. Waiting');
var $this = this;
setTimeout(function () {
- $this.texturesLoaded(t1, t2, callback);
+ $this.texturesLoaded(t1, t2, dir, callback);
}, 500);
return;
}
this.ready = true;
this.resize();
+
callback();
},
callback(texture);
},
- playTurn: function (dir, callback, timeScale, delay) {
- if (this.turnRunning) {
- return;
- }
- if (timeScale === undefined) {
- timeScale = 1;
- }
-
- var $this = this;
-
+ initTurn: function (dir) {
this.turnRunning = true;
this.tlname = dir === 1 ? 'right' : 'left';
this.progressAnimation(0);
this.animate(false);
+ this.resize();
+ },
+
+ playTurn: function (dir, callback, timeScale, delay) {
+ if (!this.turnRunning) {
+ this.initTurn(dir);
+ }
+
+ if (timeScale === undefined) {
+ timeScale = 1;
+ }
+
+ var $this = this;
+
if (delay === undefined) {
delay = this.fluidbook.support.iOS ? 0.15 : 0.06;
}
- this.resize();
-
TweenMax.fromTo(this, this.animationTime * timeScale,
{progressAnimation: 0,},
{
});
}
-
var render = true;
+ var visible;
if (this._progressAnimation < 1) {
if (this.turnRunning) {
if (this.performancesTestRunning) {
this.performancesFrames++;
}
render = true;
- this.setJContainerVisibility(true);
+ visible = true;
} else {
render = false;
- this.setJContainerVisibility(false);
+ visible = false;
}
} else {
render = false;
- this.setJContainerVisibility(false);
+ visible = false;
}
+
if (render) {
var d = ((720 + this._pageRotation) % 360);
this.plane.rotation.y = d * this.deg2rad;
this.modifier && this.modifier.apply();
}
+ this.setJContainerVisibility(visible);
+
if (this._callbackAfterNextRender !== null) {
try {
var c = this._callbackAfterNextRender;
this.fluidbook.loader.preloadPagesBeforeTransition(turning.end, function () {
$this.flip3d.clean();
$this.flip3d.prepareTurn(turning, function () {
- $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () {
- $this.beforeTransition(pageNr, 3, turning);
- $this.flip3d.playTurn(turning.dir, function () {
- $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.end, true, function () {
- $this.afterTransition(pageNr);
+ $this.beforeTransition(pageNr, 3, turning);
+ $this.flip3d.initTurn(turning.dir);
+ setTimeout(function(){
+ $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () {
+ $this.flip3d.playTurn(turning.dir, function () {
+ $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.end, true, function () {
+ $this.afterTransition(pageNr);
+ });
});
});
- });
+ },10);
});
});
},