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
Style = require '../styles/props' | |
_ = require 'lodash' | |
module.exports = | |
_setScreenWidth: -> | |
if @isMounted() then @setState {screenWidth: window.innerWidth} | |
getInitialState: -> screenWidth: window?.innerWidth or 1280 | |
screenWidth: (minName, maxName) -> |
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 React, { Component } from 'react'; | |
// Usage: | |
// | |
// @Stateful({ | |
// initialize(props) { | |
// return { | |
// count: 0 | |
// }; | |
// }, |
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
module.exports = React.createClass | |
displayName: 'InViewWrapper' | |
propsTypes: | |
onInView: React.PropTypes.func.isRequired | |
inViewOffset: React.PropTypes.number | |
getDefaultProps: -> | |
inViewOffset: 0 |
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 React = require('react'); | |
class AutoBindingComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
for (var property in this) { | |
if (this.hasOwnProperty(property) && typeof this[property] === 'function') { | |
this[property] = this[property].bind(this); | |
} |
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 Alt from './' | |
// the magic sauce | |
import { createTransform } from './utils/frp' | |
// decorator utilities | |
import { createStore, bind } from './utils/decorators' | |
const alt = new Alt() |
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
module.exports = React.createClass({ | |
displayName : 'LazyRender', | |
getInitialState() { return { props : this.props } }, | |
componentWillReceiveProps(newProps) { setTimeout(() => this.setState(newProps), 10) }, | |
shouldComponentUpdate(newProps, newState) { return this.state !== newState; }, | |
render() { return React.cloneElement(React.Children.only(this.props.children), this.state); } | |
}); |
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 React, {Component} from 'react'; | |
import request from 'superagent-bluebird-promise'; | |
class AjaxGet extends Component { | |
constructor(props, context) { | |
super(props, context); | |
this.state = { | |
data: {} | |
}; |
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 logtime = (function() { | |
var ids = {}; | |
return function(id) { | |
if (!ids[id]) { | |
ids[id] = +new Date(); | |
return; | |
} | |
var time = +new Date() - ids[id]; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>RequireJS</title> | |
<script data-main="scripts/main" src="scripts/require.js"></script> | |
</head> | |
<body> | |
<div id="coordinates">0,0</div> | |
<div id="delta">0</div> | |
<ul id="buffer"></ul> |
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
/*global CodeMirror */ | |
function indexOf(string, pattern, from) { | |
if (typeof pattern === "string") { | |
var found = string.indexOf(pattern, from); | |
return found; | |
} | |
var m = pattern.exec(from ? string.slice(from) : string); | |
return m ? (m.index + from) : -1; | |
} |