<p>
<button class="show">show</button> <button class="hide">hide</button>
</p>
<p class="animation-container"></p>
This file contains hidden or 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
/** | |
* All credit goes to Rich Harris | |
* https://github.com/Rich-Harris/yootils/blob/master/scripts/check-treeshaking.js | |
*/ | |
const { rollup } = require('rollup'); | |
async function check() { | |
const bundle = await rollup({ | |
input: 'scripts/check-treeshaking-entry.js', | |
onwarn: (warning, handle) => { |
This file contains hidden or 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
export const debounce = (fn, delay = 0, context = null) => { | |
let timeout = null; | |
const debounced = (...args) => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => fn.apply(context, args), delay); | |
}; | |
debounced.cancel = () => clearTimeout(timeout); |
This file contains hidden or 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 from 'react' | |
const { func, bool } = React.PropTypes | |
export default class AsyncComponent extends React.Component { | |
static propTypes = { | |
resolve: func.isRequired, | |
showProcess: bool | |
} |
This file contains hidden or 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
class HtmlAdditionalChunksPlugin { | |
constructor(chunks = []) { | |
this.chunks = chunks | |
this.onBeforeGeneration = 'html-webpack-plugin-before-html-generation' | |
} | |
findChunk(chunk, chunkName) { | |
return Array.isArray(chunk.names) && chunk.names[0] === chunkName | |
} |
This file contains hidden or 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 from 'react' | |
const {oneOf, node, func, oneOfType} = React.PropTypes | |
const isMobile = /Mobi/.test(window.navigator.userAgent || '') | |
const device = { | |
mobile: isMobile, | |
desktop: !isMobile | |
} |
This file contains hidden or 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' | |
export default class ResizeListener extends Component { | |
static defaultProps = { | |
onResize: Function.prototype, | |
getDOMNode: Function.prototype | |
} | |
constructor(...args) { | |
super(...args) |
This file contains hidden or 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 from 'react'; | |
import { Motion, spring, presets } from 'react-motion'; | |
import Swipeable from './Swipeable'; | |
import styled from 'styled-components' | |
const ReseteUl = styled.ul` | |
margin: 0; | |
padding: 0; |
This file contains hidden or 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 BinarySearchTree (rootData) { | |
this.root = null; | |
this.nodes = 0; | |
this.add(rootData); | |
} | |
BinarySearchTree.prototype = { | |
constructor : BinarySearchTree, | |
add : function add (data) { | |
if (this.root === null) { |
This file contains hidden or 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
// first = true - find first occurance | |
// first = false - find last occurance | |
// first = undefined - first found | |
function binarySearch(array, x, first) { | |
var start = 0, end = array.length - 1, mid = 0, result = -1; | |
while (start <= end) { | |
mid = Math.floor((start + end) / 2); | |
if (array[mid] == x) { | |
result = mid; |
NewerOlder