Skip to content

Instantly share code, notes, and snippets.

View Go7hic's full-sized avatar
👓
👖

Go7hic Go7hic

👓
👖
View GitHub Profile
@Go7hic
Go7hic / stringrender.js
Last active February 6, 2017 14:03
ES6 字符串模板渲染函数 #tags: ES6
function render (template, options) {
return template.replace(/\{\{\s?(\w+)\s?\}\}/g, (match, variable) => {
return options[variable] || ''
})
}
@Go7hic
Go7hic / input.html
Created September 7, 2016 12:46
input type number
<!DOCTYPE html>
<html lang="en">
<head>
<title>input</title>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"
/>
<style>
@Go7hic
Go7hic / what-forces-layout.md
Created June 13, 2016 01:39 — 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()
@Go7hic
Go7hic / checkie.js
Last active February 7, 2017 03:29
判断ie浏览器 #tags: IE
//ie9-
var isIE9_ = document.all && !window.atob;
// ie8-
var isIE8_ = document.all && !document.addEventListener;
var isIE8_ = '\v'=='v';
var isIE8_ = !+'\v1';
// ie7-
@Go7hic
Go7hic / jspattern.js
Last active February 7, 2017 03:41
JS 设计模式 #tags: 设计模式
// 策略模式
var validator = {
types: {},
messages: [],
config: {},
validate: function (data) {
var obj = {
value = 1,
increment: function() {
this.value += 1;
return this;
},
add: function (v) {
this.value += v;
return this
},
// Sort Numbers
function solution(nums){
return (nums || []).sort(function(a, b){
return a - b
});
}
// -------------------------------------------------------------------------------------------------------------------------
// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
@Go7hic
Go7hic / gist:169685f6d66b3bc10f4e
Last active August 5, 2018 05:58
canvas做的背景
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景</title>
<style>
* {
margin: 0;
padding: 0;
}
@Go7hic
Go7hic / Javascript排序算法
Created May 8, 2014 15:26
Javascript排序算法
// JS排序算法
var Sort = {}
Sort.prototype = {
// 利用sort进行排序
systemSort:function(array){
return array.sort(function(a, b){
return a - b;
});
},
@Go7hic
Go7hic / js自动轮播效果
Last active June 14, 2016 11:18
7-1 js自动轮播效果
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js图片轮播</title>
<style>
body,div,ul,li{margin:0;padding:0;}
ul{list-style-type:none;}
body{background:#000;text-align:center;font:12px/20px Arial;}
#box{position:relative;width:492px;height:172px;background:#fff;border-radius:5px;border:8px solid #fff;margin:10px auto;cursor:pointer;}