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
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/Animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require('enyo');
var
kind = require('./kind'),
utils = require('./utils'),
easing = require('./easing'),
animation = require('./animation');

var
Expand Down Expand Up @@ -145,7 +146,7 @@ module.exports = kind(
* @default module:enyo/easing~easing.cubicOut
* @public
*/
easingFunction: animation.easing.cubicOut
easingFunction: easing.cubicOut
},

/*
Expand Down
22 changes: 22 additions & 0 deletions src/SceneSupport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var
kind = require('./kind'),
utils = require('./utils'),
scene = require('./scene');

var SceneSupport = {

create: kind.inherit(function(sup) {
var sctor;
return function() {
sup.apply(this, arguments);
sctor = this.scene;
if (sctor) {
sctor = scene(this, sctor);
utils.mixin(sctor, this.sceneOptions);
this.scene = sctor;
}
};
})
};

module.exports = SceneSupport;
95 changes: 43 additions & 52 deletions src/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ var ms = Math.round(1000/60),
cRAF = 'cancelRequestAnimationFrame',
cAF = 'cancelAnimationFrame',
i, pl, p, wcRAF, wrAF, wcAF,
_requestFrame, _cancelFrame, cancelFrame;
_requestFrame, _cancelFrame, cancelFrame,
core = { ts: 0, obs: {}};


/*
* Fallback on setTimeout
Expand Down Expand Up @@ -98,63 +100,36 @@ exports.cancelRequestAnimationFrame = function(id) {
exports.cancelAnimationFrame = function(id) {
return _cancelFrame(id);
};

/**
* A set of interpolation functions for animations, similar in function to CSS3
* transitions.
* Subcribes for animation frame ticks.
*
* These are intended for use with {@link module:enyo/animation#easedLerp}. Each easing function
* accepts one (1) [Number]{@glossary Number} parameter and returns one (1)
* [Number]{@glossary Number} value.
* @param {Object} ctx - The context on which callback is registered.
* @param {Function} callback - A [callback]{@glossary callback} to be executed on tick.
* @public
*/
exports.subscribe = function(ctx,callback) {
var id = utils.uid("rAF");
core.obs[id] = utils.bindSafely(ctx, callback);
return id;
};
/**
* Unsubcribes for animation frame ticks.
*
* @param {Object} node - The context on which callback is registered.
* @param {Function} callback - A [callback]{@glossary callback} to be executed on tick.
* @public
*/
exports.easing = /** @lends module:enyo/animation~easing.prototype */ {
/**
* cubicIn
*
* @public
*/
cubicIn: function(n) {
return Math.pow(n, 3);
},
/**
* cubicOut
*
* @public
*/
cubicOut: function(n) {
return Math.pow(n - 1, 3) + 1;
},
/**
* expoOut
*
* @public
*/
expoOut: function(n) {
return (n == 1) ? 1 : (-1 * Math.pow(2, -10 * n) + 1);
},
/**
* quadInOut
*
* @public
*/
quadInOut: function(n) {
n = n * 2;
if (n < 1) {
return Math.pow(n, 2) / 2;
}
return -1 * ((--n) * (n - 2) - 1) / 2;
},
/**
* linear
*
* @public
*/
linear: function(n) {
return n;
}
exports.unsubscribe = function(id) {
delete core.obs[id];
};

var startrAF = function(){
_requestFrame(function (time) {
startrAF();
core.ts = time;
}.bind(this));
};
startrAF();

/**
* Gives an interpolation of an animated transition's distance from 0 to 1.
Expand Down Expand Up @@ -206,3 +181,19 @@ exports.easedComplexLerp = function(t0, duration, easing, reverse, time, startVa
return easing(lerp, time, startValue, valueChange, duration);
}
};


//TODO: A temporary implementation for rAF with observers.
Object.defineProperty(core, 'ts', {

get: function() {
return this.value;
},

set: function(newValue) {
for(var i in this.obs){
this.obs[i](this.value, newValue);
}
this.value = newValue;
}
});
Loading