Skip to content

Instantly share code, notes, and snippets.

@huzidaha
huzidaha / non-react-redux.html
Last active August 27, 2021 01:59
Using redux non-react project.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src='./jquery-v3.0.0.js'></script>
<script src='./redux-v3.6.0.min.js'></script>
<title>Document</title>
</head>
@huzidaha
huzidaha / mvvm.js
Created June 10, 2017 08:48
ScriptOJ MVVM(勉强符合题意版本,可以优化地方很多)
const bindViewToData = (el, data) => {
Object.keys(data).forEach((k) => {
let v = data[k]
Object.defineProperty(data, k, {
get () {
return v
},
set (nv) {
v = nv
@huzidaha
huzidaha / Component.js
Last active February 23, 2017 08:36
React.js in 40 Lines.js
const createDOMFromString = (domString) => {
const div = document.createElement('div')
div.innerHTML = domString
return div
}
class Component {
constructor (props = {}) {
this.props = props
}
@huzidaha
huzidaha / what-forces-layout.md
Created January 22, 2017 16:07 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()