Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rAF with observers #1446

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ffa87ef
rAF with observers
anishramesan May 12, 2016
cbe9849
travis fixes
anishramesan May 13, 2016
b8e81ab
Merge latest changes from branch 'sceneapproach'
ankurmishra32 May 20, 2016
596829f
updates with multiple scenes and sequence
anishramesan May 20, 2016
8dd854a
Change the observer implementation from array to object
sriramas May 23, 2016
1c233dd
Fix bug in animation repeat and introduce fillmode
ankurmishra32 May 24, 2016
5806bea
sequence updates
anishramesan May 24, 2016
f7a0b7c
Added setAnimation feature to FW
cholanmadala May 27, 2016
c1bf240
Fix some coding issue
ankurmishra32 May 30, 2016
de49297
Added sceneSupport mixin
cholanmadala May 31, 2016
2c4008e
Now support duration in %
ankurmishra32 Jun 1, 2016
6ed52b8
Added prepareAnimate api
cholanmadala Jun 1, 2016
36b6896
Update comments for scene
sriramas Jun 6, 2016
d626583
Defect fixes and Review changes
cholanmadala Jun 6, 2016
ba6621f
Defect fix in Kind
cholanmadala Jun 6, 2016
e6a016e
Code optimizations in Scene
cholanmadala Jun 7, 2016
e7c957b
removed consoles
cholanmadala Jun 7, 2016
7e1ffc5
Correct repeat related issue in various scene scenario
ankurmishra32 Jun 8, 2016
89da743
Update comments for transform
sriramas Jun 10, 2016
20142ad
Name of the module capitalized
cholanmadala Jun 15, 2016
d850434
API updates
anishramesan Jun 15, 2016
8a02ea7
removed sceneSupport
anishramesan Jun 15, 2016
d20135f
added SceneSupport
anishramesan Jun 15, 2016
b052676
Accept duration in % during runtime
ankurmishra32 Jun 16, 2016
97d25e6
Merge code fixes
anishramesan Jun 16, 2016
d1cfcab
easing documentation
anishramesan Jun 16, 2016
4438b93
easing update
anishramesan Jun 16, 2016
fed3bfd
Update remaining easing
ankurmishra32 Jun 17, 2016
40dfb4f
tween api documented
anishramesan Jun 17, 2016
5e87d50
Some bug fix related to non transformable properties
ankurmishra32 Jun 17, 2016
de78f70
Replace switch case in 'formatTransformValues' function
ankurmishra32 Jun 17, 2016
e3cbd9b
Made correction in time comparision
ankurmishra32 Jun 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comments for scene
sriramas committed Jun 6, 2016
commit 36b68964e2c7103062c1aea78c7a513af9f14bec
144 changes: 95 additions & 49 deletions src/scene.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ var
tween = require('./tween'),
utils = require('./utils'),
animation = require('./animation');
/**
* Contains the declaration for the {@link module:enyo/scene~scene} kind.
* @module enyo/scene
*/

var _ts, _framerate = 16.6;

@@ -44,10 +48,9 @@ var AnimationSupport = {
isSequence: true,

/**
* Starts the animation of the <code>actor</code> given in argument.
* If actor is not provided, animation of all the components linked to the {@link module:enyo/AnimationSupport/Scene} will be started.
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* Starts the animation of scene.
* @public
* @memberOf module:enyo/scene
*/
play: function () {
this.direction = this.speed = 1;
@@ -59,9 +62,8 @@ var AnimationSupport = {
},

/**
* Resumes the paused animation of the <code>actor</code> given in argument.
* If actor is not provided, animation of all the components linked to the {@link module:enyo/AnimationSupport/Scene} will be resumed.
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* Resumes the paused animation of scene.
* @memberOf module:enyo/scene
* @public
*/
resume: function() {
@@ -70,9 +72,8 @@ var AnimationSupport = {
},

/**
* Pauses the animation of the <code>actor</code> given in argument.
* If actor is not provided, animation of all the components linked to the {@link module:enyo/AnimationSupport/Scene} will be paused.
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* Pauses the animation of scene.
* @memberOf module:enyo/scene
* @public
*/
pause: function () {
@@ -81,19 +82,17 @@ var AnimationSupport = {
},

/**
* Reverses the animation of the <code>actor</code> given in argument.
* If actor is not provided, animation of all the components linked to the {@link module:enyo/AnimationSupport/Scene} will be reversed.
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* Reverses the animation of scene.
* @memberOf module:enyo/scene
* @public
*/
reverse: function () {
this.direction = -1;
},

/**
* Stops the animation of the actor given in argument.
* If actor is not provided, animation of all the components linked to the {@link module:enyo/AnimationSupport/Scene} will be stopped.
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* Stops the animation of scene.
* @memberOf module:enyo/scene
* @public
*/
stop: function () {
@@ -102,21 +101,21 @@ var AnimationSupport = {
},

/**
* Seeks the animation of the <code>actor</code> to the position provided in <code>seek</code>
* Seeks the animation to the position provided in <code>seek</code>
* The value of <code>seek</code> should be between <b>0</b> to <code>duration</code> of the animation.
* @param {Number} seek Value in seek where the animation has to be seeked
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* @param {Number} seek where the animation has to be seeked
* @memberOf module:enyo/scene
* @public
*/
seek: function(seek) {
this.timeline = seek;
},

/**
* Seeks <code>actor</code> with animation to the position provided in <code>seek</code>
* Seeks the animation to the position provided in <code>seek</code> with animation
* The value of <code>seek</code> should be between <b>0</b> to <code>duration</code> of the animation.
* @param {Number} seek Value in seek where the animation has to be seeked
* @param [Component]{@link module:enyo/Component~Component} actor The component to be animated
* @param {Number} seek where the animation has to be seeked
* @memberOf module:enyo/scene
* @public
*/
seekAnimate: function(seek) {
@@ -137,26 +136,28 @@ var AnimationSupport = {
//TODO: Move these events to Event Delegator
/**
* Event to identify when the scene has done animating.
* @memberOf module:enyo/AnimationSupport/Actor
* @memberOf module:enyo/scene
* @public
*/
completed: function() {},

/**
* Event to identify when the scene has done a step(rAF updatation of time) in the animation.
* @memberOf module:enyo/AnimationSupport/Actor
* @memberOf module:enyo/scene
* @public
*/
step: function() {}
};

/**
* {@link module:enyo/Scene~Scene} is a work-in-progress module
* {@link module:enyo/Scene~Scene}
*
* @class Scene
* @extends module:enyo/Scene~Scene
* @wip
* @private
* @param {Object} actor component which has to be animated
* @param {Object} props properties of the component
* @param {Object} opts additional options
* @public
*/
var scene = module.exports = function (actor, props, opts) {
this.id = utils.uid("@");
@@ -177,22 +178,31 @@ var scene = module.exports = function (actor, props, opts) {
}
}
};

/**
* Checks whether the scene is in a active state, which then can be animated
* @return {Boolean} generated value in true or false. true in case of the parent scene
* @memberOf module:enyo/scene
* @public
*/
scene.prototype.isActive = function () {
if (this.actor)
return this.actor.generated;

// making sure parent scenes are always active.
return true;
};

/**
* @private
*/
function modify(pose, currentTm) {
pose.span = currentTm;
delete pose._endAnim;
pose._endAnim = pose.currentState;
return pose;
};

}
/**
* @private
*/
function currPose(poseArr, tm, properties) {
var currentTime = tm;
for (var i = 0; i < poseArr.length; i++) {
@@ -208,8 +218,10 @@ function currPose(poseArr, tm, properties) {
break;
}
}
};

}
/**
* @private
*/
function hasPosesCheck(poseArr) {
var bool;
for (var i = 0; i < poseArr.length; i++) {
@@ -219,8 +231,10 @@ function hasPosesCheck(poseArr) {
}
}
return bool;
};

}
/**
* @private
*/
function loopPose(poseArr, tm, properties) {
var isArrayCheck, hasPoses;
isArrayCheck = utils.isArray(poseArr);
@@ -233,20 +247,38 @@ function loopPose(poseArr, tm, properties) {
} else if (isArrayCheck === true && hasPoses === false) {
currPose(poseArr, tm, properties);
}
};

}

/**
* Sets the new animations with the properties passed.
* @param {Object} properties Animation properties
* @memberOf module:enyo/scene
* @public
*/
scene.prototype.setAnimation = function(properties) {
var currentTime, currentPose;
currentTime = this.timeline; // current time
posesList = this.poses; // gets the poses
loopPose(posesList, currentTime, properties);
};

/**
* Gets the current animation pose.
* @param {Number} index animation index
* @return {Object} pose pose with the passed index
* @memberOf module:enyo/scene
* @public
*/
scene.prototype.getAnimation = function(index) {
return index < 0 || this.poses[index];
};

/**
* addAnimation is used for adding new animation with the passed properties at run time.
* @param {Object} newProp animation properties for new animation
* @param {Number} span span between the animation
* @param {Number} dur duration for the new animation
* @memberOf module:enyo/scene
* @public
*/
scene.prototype.addAnimation = function(newProp, span, dur) {
var l = this.poses.length,
old = 0,
@@ -260,7 +292,9 @@ scene.prototype.addAnimation = function(newProp, span, dur) {
this.poses.push({animate: newProp, span: newSpan, begin: old });
this.span = newSpan;
};

/**
* @private
*/
scene.prototype.action = function(ts, pose) {
var tm, i, poses,
dur = this.span;
@@ -294,7 +328,9 @@ scene.prototype.action = function(ts, pose) {
}
return pose;
};

/**
* @private
*/
scene.prototype.cut = function () {
if (this.handleLayers) {
this.speed = 0;
@@ -306,15 +342,22 @@ scene.prototype.cut = function () {
this.animating = false;
this.completed && this.completed(this.actor);
};

/**
* @private
*/
scene.prototype.toScene = function (scene) {
scene.speed = this.speed;
scene.direction = this.direction;
scene.handleLayers = this.handleLayers;
return scene;
};


/**
* Add a new animation scene for the animation.
* @param {Object} sc scene which has to be added
* @memberOf module:enyo/scene
* @public
*/
scene.prototype.addScene = function(sc) {
var l = this.poses.length,
old = 0,
@@ -331,18 +374,21 @@ scene.prototype.addScene = function(sc) {
this.span = newSpan;
};



/**
* @private
*/
function loop (was, is) {
if (this.animating) {
_ts = is - (was || 0);
_ts = (_ts > _framerate) ? _framerate : _ts;
this.action(_ts);
} else if (this.actor && this.actor.destroyed) {
animation.unsubscribe(this.rAFId);
animation.unsubscribe(this.rAFId);
}
}

/**
* @private
*/
function update (pose, actor, since, dur) {
var t;
if (!pose._startAnim) tween.init(actor, pose);
@@ -374,15 +420,15 @@ function rolePlay (t, actor) {
actor.speed = 0;
}
}

if (actor.timeline === undefined || actor.timeline < 0)
actor.timeline = 0;
return actor.timeline;
}

/**
* Returns animation pose index for a particular
* instance of time from the list of
* Returns animation pose index for a particular
* instance of time from the list of
* animations added to the scene.
* @param {number} span - Time span from the animation timeline
* @return {number} - index of the animation