Skip to content

Instantly share code, notes, and snippets.

Ben Robertson benjamingrobertson

Block or report user

Report or block benjamingrobertson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@benjamingrobertson
benjamingrobertson / lazy-video-loader.js
Last active May 20, 2019
Lazy Loading Video Based on Connection Speed
View lazy-video-loader.js
class LazyVideoLoader {
constructor() {
this.videos = [].slice.call(document.querySelectorAll('.hero__bgvideo'));
// Abort when:
// - The browser does not support Promises.
// - There no videos.
// - If the user prefers reduced motion.
// - Device is mobile.
if (
@benjamingrobertson
benjamingrobertson / scrollchange.js
Last active Jan 16, 2017
A simple javascript module for adding a class to an element depending if it is visible or not.
View scrollchange.js
// Use it like this:
// ScrollChange.init('.featured-on', 'featured-on--fixed');
var ScrollChange = {
element: '',
windowHeight: '',
elementTop: '',
lastScrollTop: 0,
delta: 50,
didScroll: false,
You can’t perform that action at this time.