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 im.wsb.example
import java.lang.reflect.Field;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.AbsListView;
import android.widget.ListView;
<!DOCTYPE html>
<html>
<head>
<title>Tap to Zoom</title>
<!-- include rebound and the exported code -->
<script src="http://facebook.github.io/rebound-js/rebound.min.js"></script>
<script src="origami_code_export.js"></script>
<!-- write some simple css to layout your layers -->
@willbailey
willbailey / index.html
Last active August 29, 2015 14:16
Origami HTML Code Export Tap to Zoom
<!DOCTYPE html>
<html>
<head>
<title>Tap to Zoom</title>
<!-- include rebound and the exported code -->
<script type="text/javascript" src="http://facebook.github.io/rebound-js/rebound.min.js"></script>
<script type="text/javascript" src="origami_code_export.js"></script>
<!-- write some simple css to layout your layers -->
<style type="text/css">
var extend = rebound.util.extend,
SpringSystem = rebound.SpringSystem,
MathUtil = rebound.MathUtil;
var springSystem = new SpringSystem();
/** Animation **/
var Animation = function(layers, transitions) {
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 = el.style.msTransform =
@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,
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 =
'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 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;
};
@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.