2a5bac2bb3
* major JSDoc write up * removed ESLint `no-bitwise` exception, it only applies to specific functions and not the entire code * the `SVGCubicMorph` component will remove un-necessary `Z` path commands when is the case for better out of the box animation * fixed a minor disambiguation with `filterEffects` and `drop-shadow` property and its `dropshadow` interpolation function * TypeScript strong: all files are modules, easy to implement in any third party app * updated `CubicBezier` and SVGPathCommander * code cleanup
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
import numbers from '../interpolation/numbers';
|
|
|
|
import {
|
|
scrollContainer,
|
|
onStartScroll,
|
|
onCompleteScroll,
|
|
scrollIn,
|
|
scrollOut,
|
|
getScrollTargets,
|
|
preventScroll,
|
|
toggleScrollEvents,
|
|
} from './scrollPropertyBase';
|
|
|
|
// Component Functions
|
|
/**
|
|
* Returns the current property computed style.
|
|
* @returns {number} computed style for property
|
|
*/
|
|
function getScroll() {
|
|
this.element = ('scroll' in this.valuesEnd) && (!this.element || this.element === window)
|
|
? scrollContainer : this.element;
|
|
|
|
return this.element === scrollContainer
|
|
? (window.pageYOffset || scrollContainer.scrollTop)
|
|
: this.element.scrollTop;
|
|
}
|
|
|
|
/**
|
|
* Returns the property tween object.
|
|
* @param {string} _ the property name
|
|
* @param {string} value the property value
|
|
* @returns {number} the property tween object
|
|
*/
|
|
function prepareScroll(/* prop, */_, value) {
|
|
return parseInt(value, 10);
|
|
}
|
|
|
|
// All Component Functions
|
|
const scrollFunctions = {
|
|
prepareStart: getScroll,
|
|
prepareProperty: prepareScroll,
|
|
onStart: onStartScroll,
|
|
onComplete: onCompleteScroll,
|
|
};
|
|
|
|
// Full Component
|
|
const ScrollProperty = {
|
|
component: 'scrollProperty',
|
|
property: 'scroll',
|
|
defaultValue: 0,
|
|
Interpolate: { numbers },
|
|
functions: scrollFunctions,
|
|
// export stuff to global
|
|
Util: {
|
|
preventScroll, scrollIn, scrollOut, getScrollTargets, toggleScrollEvents,
|
|
},
|
|
};
|
|
|
|
export default ScrollProperty;
|