Skip to content

Commit

Permalink
Allow space-separated easings in token preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
bdowning committed Apr 20, 2016
1 parent 3c264a0 commit 722ff31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/preprocessors/tokenPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export function createTokenPreprocessor(options = { }) {
const parts = state[prop].split(/(\d+(?:\.\d+|\.)?|\.\d+)/);
const values = [ ];

if (typeof easing[prop] === 'string' && easing[prop].match(/\s/)) {
easing[prop] = easing[prop].split(/\s+/);
}

for (let i = 1; i < parts.length; i += 2) {
values.push({
value: parts[i],
Expand Down
11 changes: 11 additions & 0 deletions test/preprocessors/tokenPreprocessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ describe('tokenPreprocessor', () => {

expect(outEasing).toEqual({ x__0: customEasing, x__1: identity, x__2: customEasing });
});

it('allows multiple easings as a space-separated string', () => {
const customEasing = x => x;
const tokenPreprocessor = createTokenPreprocessor();

const [ outState, outEasing, decode ] =
tokenPreprocessor({ x: 'transformX(1px) rotate(5deg) scale(0.27)' },
{ x: 'customEasing identity customEasing' });

expect(outEasing).toEqual({ x__0: 'customEasing', x__1: 'identity', x__2: 'customEasing' });
});
});

0 comments on commit 722ff31

Please sign in to comment.