this._progressAnimation = 0;
this._pageRotation = 0;
this.ready = false;
- this.animationTime = parseFloat(this.fluidbook.datas.mobileTransitionDuration);
+ this.animationTime = parseFloat(this.fluidbook.datas.mobileTransitionDuration) * 15;
this.textures = [];
this.lowPerf = this.fluidbook.support.android || this.fluidbook.support.iOS || this.fluidbook.support.IE > 0;
this.turnRunning = false;
+ this.pi2 = Math.PI * 2;
+ this.deg2rad = this.pi2 / 360;
+
var $this = this;
this.init();
}
this.initAnimations();
- this.animate();
-
+ this.animate(true);
this.resize();
},
ease: Power0.easeIn
}));
this.tlleft.add(TweenMax.fromTo(this.bend, 5, {force: force}, {force: 0, ease: Power0.easeOut}));
- this.tlleft.add(TweenMax.fromTo(this, 10, {_pageRotation: 0}, {
- _pageRotation: 180,
+ this.tlleft.add(TweenMax.fromTo(this, 10, {_pageRotation: -180}, {
+ _pageRotation: -0,
ease: Power1.easeIn
}), 0);
this.tlleft.pause();
var $this = this;
this.prepareTexture(turning.flip[1], function (t1) {
$this.prepareTexture(turning.flip[0], function (t2) {
- $this.texturesLoaded(t1, t2, turning.dir, callback);
+ $this.texturesLoaded(t1, t2, callback);
});
})
},
- texturesLoaded: function (t1, t2, dir, callback) {
- this.tlname = dir === 1 ? 'right' : 'left';
-
- this.tlleft.kill();
- this.tlright.kill();
- this.progressAnimation(0);
-
+ texturesLoaded: function (t1, t2, callback) {
this.textures[0].map = t1;
this.textures[1].map = t2;
};
},
- playTurn: function (callback) {
- var $this = this;
+ playTurn: function (dir, callback) {
if (this.turnRunning) {
return;
}
+
+ var $this = this;
+
+ this.tlleft.kill();
+ this.tlright.kill();
+
+ this.tlname = dir === 1 ? 'right' : 'left';
this.progressAnimation(0);
- this.turnRunning = true;
- TweenMax.fromTo(this, this.animationTime,
- {
- progressAnimation: 0
- }, {
- progressAnimation: 1,
- ease: Power0.easeIn,
- onComplete: function () {
- $this.turnRunning = false;
- callback();
- }
- }
- );
+ this.turnRunning = true;
+ $this.animate(false);
+
+ // TweenMax.fromTo(this, this.animationTime,
+ // {
+ // progressAnimation: 0
+ // }, {
+ // progressAnimation: 1,
+ // ease: Power0.easeIn,
+ // onComplete: function () {
+ // $this.turnRunning = false;
+ // this.tlname='';
+ // callback();
+ // }
+ // }
+ // );
},
- animate: function () {
+ animate: function (next) {
var $this = this;
if (this.stats === undefined) {
try {
window.requestAnimationFrame(this.animate);
} catch (e) {
setTimeout(function () {
- $this.animate();
+ $this.animate(true);
}, 100);
}
return;
}
- requestAnimationFrame(function () {
- $this.animate();
- });
-
- var pi2 = Math.PI * 2;
-
- var r = this._pageRotation / 360 * pi2;
- var diff = r - this.plane.rotation.y;
+ if (next) {
+ requestAnimationFrame(function () {
+ $this.animate(true);
+ });
+ }
- this.plane.rotateY(diff);
+ var d = ((720 + this._pageRotation) % 360);
+ console.log(d);
+ this.plane.rotation.y = d * this.deg2rad;
this.stats.update();
this.renderer.render(this.scene, this.camera);
},
resize: function () {
- if (!this.ready || this.turnRunning) {
+ if (!this.ready) {
return;
}
this.camera.updateProjectionMatrix();
$("#flip3dcontainer").css({width: this.pw, height: this.ph});
-
this.renderer.setSize(this.pw, this.ph);
this.guessCameraZoom();