Skip to content

Instantly share code, notes, and snippets.

View bpander's full-sized avatar

Brad Anderson bpander

  • Ann Arbor
View GitHub Profile
@bpander
bpander / parallax.js
Created September 24, 2012 17:16
parallax framework for creating Tweens and Switches based on the user's scroll position
/**
* parallax.js
* @author Brad Anderson
* @description Tween elements based on the users scroll position or flip a switch when the user gets to a certain point in the page
* @requires Nothing
* @example
* var tween = new parallax.Tween(
document.getElementById('pizza'),
'left',
'0px',
@bpander
bpander / JS Module Definition
Created August 31, 2013 05:35
How to define a js module
(function (definition) {
// Turn off strict mode for this function so we can assign to global
/* jshint strict: false */
// Montage Require
if (typeof bootstrap === "function") {
bootstrap("promise", definition);
// CommonJS
} else if (typeof exports === "object") {
Tiles.prototype.renderTiles = function (tiles) {
var self = this;
var renderedHTMLString = _tileTemplateCompiled(tiles);
var $parsedRender = $('<ul>' + renderedHTMLString + '</ul>').children();
return Util.imagesLoaded($parsedRender).then(function () {
$parsedRender.each(function (i, element) {
setTimeout(function () {
self.element.appendChild(element);
self.masonry.appended(element);
window.addEventListener('orientationchange', function () {
var $iframe = $('iframe');
var $parent = $iframe.parent();
var width = $iframe.parent().width();
$iframe.width(width);
setTimeout(function () {
$iframe.width('');
}, 500);
});
/*jshint node:true, laxbreak:true */
'use strict';
module.exports = function(grunt) {
var shouldMinify = (grunt.option('maps') || !grunt.option('dev'));
grunt.config.merge({
handlebars: {
compile: {
@bpander
bpander / b2SVGParser
Created February 24, 2015 02:48
Parse an svg file to create a Box2D hit box
function b2SVGParser () {
}
b2SVGParser.prototype.parse = function (svg, world, bodyDef, fixtureDef) {
fixtureDef.shape = new b2PolygonShape();
var body = world.CreateBody(bodyDef);
var traverse = function (nodes) {
var i = -1;
var node;

This "template"...

grid('.grid_relaxed', { tagName: 'section' }, [
    grid.col('.grid-col_3of12.mix-grid-col_prefix1of12', { 'data-tag': 'foo' }, [
        nav([
            vList({ tagName: 'ol' },
                data.navItems.map(navItem => {
                    h('li', [
                        nav.anchor({ href: navItem.url }, [ navItem.label ])
                    ])
// Base class
function Shape (x, y) {
this.x = x;
this.y = y;
}
<div>
<input data-props="{ onkeyup: this.handleKeyUp }" />
<div data-if="props.todos.length > 0">
<ul>
<li data-each="props.todos as todo"
data-key="todo.uuid"
data-component="Todo"
data-props="todo">
<!-- Original template -->
<ul data-each="state.todos as todo" data-key="todo.id">
<li data-component="TodoComponent">
<span>foo</span>
<div data-if="todo.complete" data-component="TodoComponent"></div>
</li>
</ul>