Skip to content

Instantly share code, notes, and snippets.

View danro's full-sized avatar
👀

Dan Rogers danro

👀
View GitHub Profile
@danro
danro / webflow-tabs-auto-scroll.html
Created October 23, 2020 03:56
Auto-scroll the browser to a clicked tabs element position
<script>
// When a tab is clicked, animate scroll to the top of the tabs element
$('.w-tab-link').on('click', function (event) {
var clickedLink = $(event.currentTarget);
var tabsElement = clickedLink.closest('.w-tabs');
var rootElement = $('html, body');
var newTop = tabsElement.offset().top;
if (rootElement.scrollTop() !== newTop) {
rootElement.stop().animate({scrollTop: newTop}, 500, 'swing');
}
const timeout = ms => new Promise(res => setTimeout(res, ms));
@danro
danro / localizer+webflow.html
Created May 18, 2016 02:05
Localizer.co script w/ Webflow Editor Compatibility
<!-- Localizer Integration Code w/ Webflow Editor Compatibility -->
<script>
var Webflow = Webflow || [];
Webflow.push(function() {
if (!window.WebflowEditor) {
$.ajax({ type: 'GET', url: '//secure.localizer.co/Replacer/?siteId=000000000', dataType: 'script', cache: true });
}
});
</script>
@danro
danro / Page-level body code.html
Created February 26, 2016 02:06
Webflow integration with fullpage.js
<script>
// Initialize fullpage plugin on document ready
Webflow.push(function() {
$('#fullpage').fullpage();
});
// Define module for Editor compatibility
Webflow.define('fullpage-destroy', function() {
return {
destroy: function() {
$.fn.fullpage.destroy('all');
@danro
danro / _test.sh
Last active August 29, 2015 14:22
No const warning 😢
./node_modules/.bin/babel test.js # SyntaxError: test.js: Line 2: "FOO" is read-only
./node_modules/.bin/eslint test.js # Nothing
@danro
danro / index.js
Created April 25, 2015 02:15
requirebin sketch
var Promise = require('promise');
var promise = new Promise(function (resolve, reject) {
resolve();
}).done(function() {
console.log('done!');
});
@danro
danro / index.js
Created April 21, 2015 00:15
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var pluralize = require('pluralize');
document.body.innerHTML = pluralize.singular('Pasties');
@danro
danro / index.js
Created January 22, 2015 21:40
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var Hogan = require('hogan.js');
var data = {
screenName: "dhg",
nested: {}
};
// validation mixin
var validation = {
getDefaultProps: function () {
return {
validate: []
}
}
, hasErrors: function () {
var errors = []
@danro
danro / index.js
Last active August 29, 2015 14:03
requirebin sketch
var mash = require('mash-js');
var withSword = mash(function () {
this.slash = function (dmg) {
console.log('Sword slash for ' + dmg + ' damage!');
};
});
var withMagic = mash(function () {
this.fireball = function (dmg) {