Skip to content

Instantly share code, notes, and snippets.

View callmecavs's full-sized avatar

Michael Cavalea callmecavs

View GitHub Profile
@callmecavs
callmecavs / randBetween.js
Created April 6, 2017 18:23
random number between 2 integers (inclusive)
// generates a random integer between min & max bounds, inclusive
const randBetween = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) + min)
}
export default randBetween
@callmecavs
callmecavs / jump.js
Last active April 14, 2017 00:08
horizontal container scrolling (modified jump.js)
// ease in out quad
const easing = (t, b, c, d) => {
t /= d / 2
if (t < 1) return c / 2 * t * t + b
t--
return -c / 2 * (t * (t - 2) - 1) + b
}
// modified jump.js
// stripped options, supports (only) scrolling a container horizontally
import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
import throttle from 'lodash/throttle'
import { INTERVAL } from './constants.js'
let bound // are the event handlers bound?
let current // current scroll position, from top of document
let queue // array of React Components to check