Skip to content

Instantly share code, notes, and snippets.

@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 / foreachloop.js
Created November 26, 2013 01:53
JavaScript foreach Loop Shorthand
for (var i = 0; i < allImgs.length; i++)
//shorthand
for(var i in allImgs)
//with array
function logArrayElements(element, index, array) {
console.log("a[" + index + "] = " + element);
}
[2, 5, 9].forEach(logArrayElements);
@nola
nola / tweenmax-scroll
Last active August 5, 2018 05:47
Calculate percentage of scroll Then uses tweenmax callbacks to continue the animation
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.10.1/TweenMax.min.js"></script>
<script>
$(function(){
@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 / objectConstructor.js
Last active January 3, 2016 06:49
creating the constructor then adding new objects via the constructor
// object constructor:
function Person(job, married) {
this.job = job;
this.married = married;
}
//function that logs info to console
function logger(x){
console.log(x)
}
@nola
nola / forloop.js
Last active January 3, 2016 06:48
for loop: outputs property name and value
var nyc = {
fullName: "New York City",
mayor: "Michael Bloomberg",
population: 8000000,
boroughs: 5
};
//This loop will output ALL the properties of this object
for(var i in nyc){
<div id="output"></div>
@nola
nola / address2.js
Last active January 3, 2016 05:59
//create an object
var friends = {};
//add people to it
friends.bill = { //observe this declaration as bill is an object of friends
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
};
@nola
nola / index.html
Created January 13, 2014 21:17
A Pen by Cyril Celestine.
<button>update</button>
<input type="text" value="10" /> <br />
<label></label>
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/