Skip to content

Instantly share code, notes, and snippets.

View willbailey's full-sized avatar

Will Bailey willbailey

  • Facebook
  • San Francisco, CA
View GitHub Profile
package com.facebook.rebound.origami;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
(function() {
var hb = {};
var deg2rad = rebound.MathUtil.degreesToRadians;
var mapVal = rebound.MathUtil.mapValueInRange;
hb.HamburgerButton = function(container, size, color, cornerRadius) {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.padding = size * 0.1;
@willbailey
willbailey / hamburgerButton.js
Created August 3, 2014 15:39
Hamburger Button Animation with Rebound JS
(function() {
var hb = {};
var deg2rad = rebound.MathUtil.degreesToRadians;
var mapVal = rebound.MathUtil.mapValueInRange;
hb.HamburgerButton = function(container, size, color, cornerRadius) {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.padding = size * 0.1;
@willbailey
willbailey / gist:56d2b94c5e9d0a9cf40c
Created September 12, 2014 17:01
SpringChain.java
package com.facebook.rebound;
import java.util.concurrent.CopyOnWriteArrayList;
public class SpringChain implements SpringListener {
private final SpringSystem mSpringSystem;
private final CopyOnWriteArrayList<SpringListener> mListeners;
private final CopyOnWriteArrayList<Spring> mSprings;
private static final SpringConfig ATTACHMENT_SPRING = SpringConfig.fromOrigamiTensionAndFriction(70, 10);
@willbailey
willbailey / SpringChain.java
Last active August 29, 2015 14:06
SpringChain.java
/*
* This file provided by Facebook is for non-commercial testing and evaluation purposes only.
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@willbailey
willbailey / AnimationQueue.java
Last active August 29, 2015 14:06
AnimationQueue.java
/*
* This file provided by Facebook is for non-commercial testing and evaluation purposes only.
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var SpringChain = function(attachmentSpringConfig, mainSpringConfig) {
this._springSystem = new rebound.SpringSystem();
this._listeners = [];
this._springs = [];
this._controlSpringIndex = -1;
this._attachmentSpringConfig = attachmentSpringConfig ||
SpringChain.DEFAULT_ATTACHMENT_SPRING_CONFIG;
this._mainSpringConfig = mainSpringConfig ||
SpringChain.DEFAULT_MAIN_SPRING_CONFIG;
};
'use strict';
var SpringChain = function(attachmentSpringConfig, mainSpringConfig) {
this._springSystem = new rebound.SpringSystem();
this._listeners = [];
this._springs = [];
this._controlSpringIndex = -1;
this._attachmentSpringConfig = attachmentSpringConfig ||
SpringChain.DEFAULT_ATTACHMENT_SPRING_CONFIG;
this._mainSpringConfig = mainSpringConfig ||
SpringChain.DEFAULT_MAIN_SPRING_CONFIG;
var xfrm = function(el, xlatX, xlatY, scale, rot) {
xlatX = typeof xlatX === 'undefined' ? 0 : xlatX;
xlatY = typeof xlatY === 'undefined' ? 0 : xlatY;
scale = typeof scale === 'undefined' ? 1 : scale;
rot = typeof rot === 'undefined' ? 0 : rot;
var xfrm =
'translate3d(' + xlatX + 'px, ' + xlatY + 'px, 0px) ' +
'scale3d(' + scale + ', ' + scale + ', 1) ' +
'rotate(' + rot + 'deg)';
el.style.mozTransform =
@willbailey
willbailey / animation.js
Created November 28, 2014 18:49
animation.js
'use strict';
// A list of layers with initial values
var layers = [
{
name: 'red-square',
width: 200,
height: 200,
x: 0,
y: 0,