Change the color of an element based on how far the page has scrolled.
Intended to fade in a fixed header as a visitor scrolls down.
Will transform from any (or no) initial colors to any colors parseable by the excelent color library.
See index.html for usage example.
Arguments
fadedHeader(headerSelector, {
transformRange: window.innerHeight,
backgroundColor: null,
textColor: null,
easingFunction: ratio => Math.pow(ratio, 2),
backgroundEasingFunction: null,
textEasingFunction: null
});
If neither backgroundColor
nor textColor
are passed, will just log and return without doing anything.
transformRange
, backgroundColor
, and textColor
can be arrays.