Skip to content

Instantly share code, notes, and snippets.

Huib van Geertruy hvgeertruy

View GitHub Profile
hvgeertruy / scroll.js
Last active Sep 3, 2018
Vanilla Javascript scroller. Done the easy way.
View scroll.js
//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.
// - 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)
hvgeertruy / breakpoint.js
Last active Jan 6, 2016
Javascript breakpoints w/ one line of script
View breakpoint.js
//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;
You can’t perform that action at this time.