Skip to content

Instantly share code, notes, and snippets.

(function() {
var banner_height = $('.collection-banner').height() + 220; //220 offset for header
var stuck = false;
var lastScrollY = 0;
var ticking = false;
var filter_dom;
var update = function() {
// do your stuff
@cameroncowden
cameroncowden / debouncer.js
Created June 24, 2018 19:08
Simple debouncer
//after a click, wait 2 seconds before showing the cta bar. if they click again, reset the timer.
// ie after 2 seconds of inactivity, show the cta
var duration;
$('.ctrl-wrapper').on("click", function(){
$('#global_cat').addClass('is-hidden'); //add class to hide cta
autoShowCta();
});
@cameroncowden
cameroncowden / validate_email.js
Created October 12, 2017 18:02
regex function for validating email input
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@cameroncowden
cameroncowden / jquery-load-throw-catch.js
Created September 27, 2017 17:56
a vanilla javascript approach to running scripts when jquery is loaded in based on a custom event
<script>
//PRE (jquery usecase only)
//load jquery library, inline or externally using defer or aysnc
console.log('jQuery321 Ready! - version: ' + jQuery321().jquery)
$j = jQuery321.noConflict(); //map to new variable (extensible)
//THROW (include this after above in jquery file)
var myElement = document.querySelector('body');
var event = document.createEvent('Event');
@cameroncowden
cameroncowden / jQuery client-side anonymous $-defining wrapper
Created July 19, 2016 17:48
A convenient little wrapper for jQuery. Useful for any small page-specific JS tweaks.
(function($){
$(window).load(function(){
//load event is sent when element and all sub-elements have been completely loaded
//includes images, scripts, frames, iframes, and the window object.
//note: care when manipulating elements visible on the initial pageload
});
$(document).ready(function(){
//fires when the dom is ready (page display might be pre- or partially- rendered)
});