Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
58
node_modules/react-smooth/src/AnimateManager.js
generated
vendored
Normal file
58
node_modules/react-smooth/src/AnimateManager.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import setRafTimeout from './setRafTimeout';
|
||||
|
||||
export default function createAnimateManager() {
|
||||
let currStyle = {};
|
||||
let handleChange = () => null;
|
||||
let shouldStop = false;
|
||||
|
||||
const setStyle = _style => {
|
||||
if (shouldStop) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(_style)) {
|
||||
if (!_style.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const styles = _style;
|
||||
const [curr, ...restStyles] = styles;
|
||||
|
||||
if (typeof curr === 'number') {
|
||||
setRafTimeout(setStyle.bind(null, restStyles), curr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setStyle(curr);
|
||||
setRafTimeout(setStyle.bind(null, restStyles));
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof _style === 'object') {
|
||||
currStyle = _style;
|
||||
handleChange(currStyle);
|
||||
}
|
||||
|
||||
if (typeof _style === 'function') {
|
||||
_style();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
stop: () => {
|
||||
shouldStop = true;
|
||||
},
|
||||
start: style => {
|
||||
shouldStop = false;
|
||||
setStyle(style);
|
||||
},
|
||||
subscribe: _handleChange => {
|
||||
handleChange = _handleChange;
|
||||
|
||||
return () => {
|
||||
handleChange = () => null;
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue