Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into greenkeeper-watchify-3.6.1
- Loading branch information
Showing
10 changed files
with
145 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {prefix} from './get-vendor-prefix'; | ||
|
||
const propertyNames = [ | ||
'name', | ||
'duration', | ||
'iterationCount', | ||
'timingFunction', | ||
'fillMode', | ||
'playState' | ||
]; | ||
|
||
/** | ||
* Returns applicable animation properties for a given node | ||
* @param {Node} node Node to read animation properties from | ||
* @param {Window} window Global context to use | ||
* @return {Object} Applicable animation properties for node in window | ||
* @private | ||
*/ | ||
export default function getAnimationProperties(node, window = global.window, document = global.document) { | ||
const styles = window.getComputedStyle(node); | ||
|
||
return propertyNames.reduce((properties, propertyName) => { | ||
const cssName = `animation${propertyName[0].toUpperCase()}${propertyName.slice(1)}`; | ||
properties[propertyName] = styles[prefix(cssName, window, document)]; | ||
return properties; | ||
}, {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
animationName: 'filled-animation', | ||
animationPlayState: 'running', | ||
animationTimingFunction: 'linear', | ||
animationDuration: '1s', | ||
animationFillMode: 'both', | ||
animationIterationCount: '10' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default { | ||
animationName: 'default-animation', | ||
animationPlayState: 'paused', | ||
animationEasing: 'linear', | ||
animationTimingFunction: 'linear', | ||
animationDuration: '300ms' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default { | ||
animationName: 'default-animation', | ||
animationPlayState: 'running', | ||
animationEasing: 'linear', | ||
animationTimingFunction: 'linear', | ||
animationDuration: '.3s' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default { | ||
animationName: 'default-animation', | ||
animationPlayState: 'running', | ||
animationEasing: 'linear', | ||
animationTimingFunction: 'linear', | ||
animationDuration: '1s' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import tape from 'tape'; | ||
import getAnimationProperties from '../../library/get-animation-properties.js'; | ||
|
||
import elementStub from './stubs/element.js'; | ||
import windowStub from './stubs/window.js'; | ||
import documentStub from './stubs/document.js'; | ||
|
||
import pausedAnimation from './fixtures/paused-animation'; | ||
import filledAnimation from './fixtures/filled-animation'; | ||
|
||
tape('get-animation-properties', t => { | ||
t.throws(() => { | ||
getAnimationProperties(); | ||
}, 'should throw when called without arguments'); | ||
|
||
t.doesNotThrow(() => { | ||
getAnimationProperties(elementStub, windowStub, documentStub); | ||
}, 'should not throw when called with arguments'); | ||
|
||
const pausedElement = { | ||
...elementStub, | ||
style: { | ||
...elementStub.style, | ||
...pausedAnimation | ||
} | ||
}; | ||
|
||
const pausedProperties = getAnimationProperties(pausedElement, windowStub, documentStub); | ||
|
||
t.deepEqual( | ||
Object.keys(pausedProperties), | ||
[ | ||
'name', | ||
'duration', | ||
'iterationCount', | ||
'timingFunction', | ||
'fillMode', | ||
'playState' | ||
], | ||
'should return an object with the expected property values'); | ||
|
||
t.deepEqual( | ||
pausedProperties, | ||
{ | ||
name: 'default-animation', | ||
duration: '300ms', | ||
iterationCount: undefined, | ||
timingFunction: 'linear', | ||
fillMode: undefined, | ||
playState: 'paused' | ||
}, | ||
'should return an object with the expected property values'); | ||
|
||
const filledElement = { | ||
...elementStub, | ||
style: { | ||
...elementStub.style, | ||
...filledAnimation | ||
} | ||
}; | ||
|
||
const filledProperties = getAnimationProperties(filledElement, windowStub, documentStub); | ||
|
||
t.deepEqual( | ||
filledProperties, | ||
{ | ||
name: 'filled-animation', | ||
duration: '1s', | ||
iterationCount: '10', | ||
timingFunction: 'linear', | ||
fillMode: 'both', | ||
playState: 'running' | ||
}, | ||
'should return an object with the expected property values'); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters