This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hoistStatics from 'hoist-non-react-statics'; | |
import React from 'react'; | |
/** | |
* Allows two animation frames to complete to allow other components to update | |
* and re-render before mounting and rendering an expensive `WrappedComponent`. | |
*/ | |
export default function deferComponentRender(WrappedComponent) { | |
class DeferredRenderWrapper extends React.Component { | |
constructor(props, context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Detect autoplay | |
// --------------- | |
// This script detects whether the current browser supports the | |
// autoplay feature for HTML5 Audio elements, and it sets the | |
// `AUTOPLAY` variable accordingly. | |
// Used in the Meteor app [PicDinner](http://picdinner.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { | |
// no easing, no acceleration | |
linear: function (t) { return t }, | |
// accelerating from zero velocity | |
easeInQuad: function (t) { return t*t }, | |
// decelerating to zero velocity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getAverageColor = (function(window, document, undefined){ | |
return function(imageURL, options}){ | |
options = { | |
// image split into blocks of x pixels wide, 1 high | |
blocksize: options.blocksize || 5, | |
fallbackColor: options.fallbackColor || '#000' | |
}; | |
var img = document.createElement('img'), | |
canvas = document.createElement('canvas'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAverageColourAsRGB (img) { | |
var canvas = document.createElement('canvas'), | |
context = canvas.getContext && canvas.getContext('2d'), | |
rgb = {r:102,g:102,b:102}, // Set a base colour as a fallback for non-compliant browsers | |
pixelInterval = 5, // Rather than inspect every single pixel in the image inspect every 5th pixel | |
count = 0, | |
i = -4, | |
data, length; | |
// return the base colour for non-compliant browsers |