Skip to content

Instantly share code, notes, and snippets.

View hvgeertruy's full-sized avatar

Huib van Geertruy hvgeertruy

  • Codezilla
  • Utrecht
View GitHub Profile
@hvgeertruy
hvgeertruy / breakpoint.js
Last active January 6, 2016 13:30
Javascript breakpoints w/ one line of script
//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;
}
@hvgeertruy
hvgeertruy / scroll.js
Last active March 28, 2024 21:41
Vanilla Javascript scroller. Done the easy way.
//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)