Skip to content

Instantly share code, notes, and snippets.

View jongacnik's full-sized avatar

Jon jongacnik

View GitHub Profile
@jongacnik
jongacnik / nohoverscroll.js
Created July 16, 2014 04:57
Disable hover states on scroll
// Plugin Idea
onScroll : function() { // disable hover events on scroll
clearTimeout(_.scrollTimer); // clear timer which checks when user stops scrolling
if(!_.timerSet){ // if we haven't started our first fire, fire it
_.timerSet = true; // tell us we've fired so we only fire once
_.scrollEnableTimer = setTimeout(function(){
if(_.timerSet){
$('body').addClass('disable-hover');
@jongacnik
jongacnik / unit.2.js
Last active August 29, 2015 14:04
Unit 2.0
/**
* Unit
*/
Site.Unit = function() {
var Data = {
setCache : function(){
}
};
@jongacnik
jongacnik / app.js
Created October 14, 2014 00:43
Load IA Posts
var s, Self = {
_data : {
},
init : function(){
Self.loadPosts();
},
parseInt(new Date()/1000);
@jongacnik
jongacnik / breakpoints.js
Last active August 29, 2015 14:08
Breakpoints module
/**
* Functionality:
* - adds breakpoint attributes to body & fires callbacks
*
* todo: callback params, height, matchMedia?
*/
var extend = require('extend');
var _data = {
currentBreakpoints : [],
var gulp = require('gulp');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var browserSync = require('browser-sync');
@jongacnik
jongacnik / scrollTo.js
Created November 15, 2014 22:58
scrollTo an element using Velocity
/**
* Functionality:
* - scrolls to an element using Velocity
*
* Assumes:
* - window.jQuery = window.$ = require('jquery');
*/
var velocity = require('velocity-animate');
// Public
@jongacnik
jongacnik / autoHeight.js
Created November 15, 2014 23:52
autoHeight returns auto height of element
/**
* Functionality:
* - returns auto height value in pixels of an element
*
* Pass in element, and optional class for dummy wrapper
*/
module.exports = function(element, uniqueClass){
var wrapper = document.createElement('div');
var clone = element.cloneNode(true);
@jongacnik
jongacnik / cbevents.js
Created November 16, 2014 18:15
Cross Browser Events
// thanks John Resig (http://ejohn.org/projects/flexible-javascript-events/)
function addEvent( obj, type, fn ) {
if ( obj.attachEvent ) {
obj['e'+type+fn] = fn;
obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
obj.attachEvent( 'on'+type, obj[type+fn] );
} else
obj.addEventListener( type, fn, false );
}
@jongacnik
jongacnik / triggerEvent.js
Created November 17, 2014 02:51
triggerEvent module
/**
* @param target is any DOM Element or EventTarget
* @param type Event type (i.e. 'click')
*/
module.exports = function(target, type) {
var doc = document;
if (doc.createEvent) {
var event = new Event(type);
target.dispatchEvent(event);
} else {