Skip to content

Instantly share code, notes, and snippets.

View suhaotian's full-sized avatar
🎯
Focusing

su suhaotian

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
ul {
margin: 0;
padding: 0;
function cached(fn) {
const cache = Object.create(null)
return function cachedFn(str) {
const hit = cache[str]
return hit || (cache[str] = fn(str))
}
}
function toCapitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
function css3(transform, value) {
const obj = {}
obj[`webKit${toCapitalize(transform)}`] = obj[transform] = value
return obj
}
// create optimized lookup object for
// void elements as listed here:
// http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
function createNullObj() {
return (Object.create) ? Object.create(null) : {};
}
/*
import React from 'react'
import Router from 'react-router/BrowserRouter'
import Match from 'react-router/Match'
import Link from 'react-router/Link'
import Redirect from 'react-router/Redirect'
// function elementInViewport(el) {
// var top = el.offsetTop
// var left = el.offsetLeft
// var width = el.offsetWidth
@suhaotian
suhaotian / Fetch.js
Created December 19, 2016 15:44
React Fetch Component
import React, { Component, PropTypes } from 'react'
//import styles from './style.css'
class ComponentName extends Component {
// static defaultProps = {}
static propTypes = {
promises: PropTypes.array.isRequired,
children: PropTypes.func.isRequired,
}
function textHidden(el, x) {
var styles = window.getComputedStyle(el)
var h = parseFloat(styles.height.replace('px', ''))
var lh = styles.lineHeight
var fontSize = parseFloat(styles.fontSize.replace('px',''))
var text = el.innerText
var w = fontSize*0.625
var ws = parseFloat(styles.width.replace('px', ''))/w
var lines = h/fontSize
<snippet>
<content><![CDATA[
import React, { Component } from 'react'
${1://}import styles from './style.css'
class ComponentName extends Component {
render() {
return (
${2:div}
import React from 'react'
import { TransitionMotion, spring } from 'react-motion'
import Match from 'react-router/Match'
const transitionMaps = {
}
const effect = {stiffness: 160, damping: 24}
import React, {Component} from 'react'
export default class DontUpdate extends Component {
shouldComponentUpdate(nextProps, nextState) {
return false
}
render() {
const { tagName, component, ...other } = this.props
const TempComponent = component ? component : (tagName ? tagName : 'div')