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
//Custom scroll animator w/ easing support & requestAnimationFrame, who needs jQuery ^ ^ | |
//Supports window (use 'window') and element (use document.querySelector(...)[0]) scrolling | |
//Want features? Use jQuery. | |
//properties: | |
// - Element: [required] The element you want the scroll to apply to. Use 'window' for window | |
// - To: [required] the offset (in px) to scroll to. Note that it will add this to the current position | |
// - Duration: [required] the duration (in ms) for the scrolling animation | |
// - Direction: [optional] (default: 'horizontal') The direction for the scrolling animation (horizontal | vertical) |
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
//The magic.. | |
function determineBreakpoint() { | |
return window.getComputedStyle(document.querySelector('.mq_current'), ':before').getPropertyValue('content').replace(/"/g,''); | |
}; | |
//Bonus: Provide a object w/ breakpoints. Ex { "l": 1, "m": 2, "s": 4 } So you won't have to process the breakpoint using a switch | |
function propertyByBreakpoint(properties) { | |
if (!properties || typeof properties !== 'object') { | |
return false; | |
} |