Skip to content

Commit

Permalink
Change to batched animation updates [fixes #87]
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Aug 10, 2018
1 parent 8e760cd commit f983ece
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 151 deletions.
2 changes: 1 addition & 1 deletion src/bezier.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const getCubicBezierTransition = (x1, y1, x2, y2) => pos =>
* attached to {@link shifty.Tweenable.formulas}.
*/
export const setBezierFunction = (name, x1, y1, x2, y2) => {
let cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);
const cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2);

cubicBezierTransition.displayName = name;
cubicBezierTransition.x1 = x1;
Expand Down
9 changes: 9 additions & 0 deletions src/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Tweenable, composeEasingObject, tweenProps } from './tweenable';
// skip uneccessary processing and object recreation, cutting down on garbage
// collection pauses.
const mockTweenable = new Tweenable();
const { filters } = Tweenable;
mockTweenable._filterArgs = [];

/**
Expand Down Expand Up @@ -49,6 +50,14 @@ export const interpolate = (from, to, position, easing, delay = 0) => {
const current = { ...from };
const easingObject = composeEasingObject(from, easing);

mockTweenable._filters.length = 0;

for (const name in filters) {
if (filters[name].doesApply(from)) {
mockTweenable._filters.push(filters[name]);
}
}

mockTweenable.set({});
mockTweenable._filterArgs = [current, from, to, easingObject];

Expand Down
3 changes: 3 additions & 0 deletions src/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ const collapseEasingObject = (easingObject, tokenData) => {
}
};

export const doesApply = fromState =>
Object.keys(fromState).some(key => typeof fromState[key] === 'string');

export function tweenCreated(currentState, fromState, toState) {
[currentState, fromState, toState].forEach(sanitizeObjectForHexProps);

Expand Down
Loading

0 comments on commit f983ece

Please sign in to comment.