Skip to content

Instantly share code, notes, and snippets.

@nola
nola / gist:6214001
Created August 12, 2013 19:05
border-box
/* apply a natural box layout model to all elements */
*, *:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
@nola
nola / smooth scroll
Created August 26, 2013 19:56
Smooth Mouse Wheel Scroll with Tween Max/ScrollTo plugin.
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
@nola
nola / cycle.js
Last active July 25, 2017 13:50
cycle tab transitions / with tweenmax
/*!
* jQuery Cycle Plugin
* Examples and documentation at: http://jquery.malsup.com/cycle/
* Copyright (c) 2007-2013 M. Alsup
* Version: 3.0.2 (19-APR-2013)
* Dual licensed under the MIT and GPL licenses.
* http://jquery.malsup.com/license.html
* Requires: jQuery v1.7.1 or later
*/
;(function($, undefined) {
@nola
nola / css
Created October 14, 2013 15:18
Scrolling background
.fullWH{
width: 100%;
height: 323px;
}
#bg1 {
background-image: url( "../img/bg1.png" );
}
#bg2 {
background-image: url( "../img/bg2.png" );
}
@nola
nola / gist:7649251
Created November 25, 2013 21:32
Console log mouse position clientY shows the Y value in pixels The second one shows event data for mousemove
$(window).on("mousemove", function (e) { console.log(e.clientY) });
$(window).on("mousemove", function (e) { console.log(e) });
@nola
nola / jquery-on-off.js
Last active December 29, 2015 09:28
example of jquery on and off, similar to bind and unbind
$(function() {
$(window).on("mousemove", mouseMoveHandler);
function mouseMoveHandler(e) {
var pos = e.clientY;
console.log(pos);
if (pos < 15) {
//key take away, is once you've got the event you want to trigger, it's good to "Turn OFF" the listner
$(window).off( "mousemove", mouseMoveHandler );
$(".footer-popup").animate({
bottom: 0
@nola
nola / js-for-loop.js
Created November 26, 2013 01:12
javascript for loop
var myLinkCollection = document.getElementsByTagName("a");
for (i=0;i<myLinkCollection.length;i++) {
if (myLinkCollection[i].getAttribute("href")) {
// do something with the anchor tags here
}
}
@nola
nola / ifelseshorthand.js
Created November 26, 2013 01:31
If true … else Shorthand
var big;
if (x > 10) {
big = true;
}
else {
big = false;
}
//Short hand version
var big = (x > 10) ? true : false;
@nola
nola / null.js
Created November 26, 2013 01:33
Null, Undefined, Empty Checks Shorthand When creating new variables sometimes you want to check if the variable your referencing for it’s value isn’t null or undefined. I would say this is a very common check for JavaScript coders.
if (variable1 !== null || variable1 !== undefined || variable1 !== '') {
var variable2 = variable1;
}
//short hand
var variable2 = variable1 || '';
@nola
nola / shortarray.js
Created November 26, 2013 01:35
Useful way of declaring small arrays on one line. Object Array Notation Shorthand
var a = new Array();
a[0] = "myString1";
a[1] = "myString2";
a[2] = "myString3";
//short hand version
var a = ["myString1", "myString2", "myString3"];