Skip to content

Instantly share code, notes, and snippets.

View Robin-front's full-sized avatar
🎯
Focusing

robin Robin-front

🎯
Focusing
  • mobvista
  • guangzhou,china
View GitHub Profile
@Robin-front
Robin-front / flexible.min.js
Created February 11, 2018 08:25
vw detect,if support, vw cooperate with rem; otherwise use flexible.js for rem
!function(){var a="@charset \"utf-8\";html{color:#000;background:#fff;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html *{outline:0;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}html,body{font-family:sans-serif}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{margin:0;padding:0}input,select,textarea{font-size:100%}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}abbr,acronym{border:0;font-variant:normal}del{text-decoration:line-through}address,caption,cite,code,dfn,em,th,var{font-style:normal;font-weight:500}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:500}q:before,q:after{content:''}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}a:hover{text-decoration:underline}ins,a{text-decor
@Robin-front
Robin-front / arrayGenerator.js
Created December 29, 2017 10:50
生成指定区间内的数字集
/**
* 生成指定区间内的数字集, 或直接指定特定数字集
* generatorBallSet(0, 5) => [0, 1, 2, 3, 4, 5]
* generatorBallSet(0, 5) => [0, 1, 2, 3, 4, 5]
* generatorBallSet([1, 3]) => [1, 3]
*/
function generatorArray(start, end) {
if (Array.isArray(start)) {
return Array.from(start);
@Robin-front
Robin-front / auto-deploy.md
Created December 9, 2017 04:47 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.

function copyStyles(sourceDoc, targetDoc) {
Array.from(sourceDoc.styleSheets).forEach(styleSheet => {
if (styleSheet.cssRules) { // for <style> elements
const newStyleEl = sourceDoc.createElement('style');
Array.from(styleSheet.cssRules).forEach(cssRule => {
// write the text of each rule into the body of the style element
newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
});
@Robin-front
Robin-front / timer.polyfill.js
Created November 9, 2017 02:45
polyfill for support passing args to timer
(function(){
var __nativeST__ = window.setTimeout,
__nativeSI__ = window.setInterval;
window.setTimeout = function (vCallback, nDelay) {
var aArgs = Array.prototype.slice.call(arguments, 2);
return __nativeST__(vCallback instanceof Function ? function () {
vCallback.apply(null, aArgs);
} : vCallback, nDelay);
function createIdleTask(){
var task = [],
timer = null;
function runTask(deadline){
var len = task.length;
while(deadline.timeRemaining() > 0 && len--) {
task.shift()();
}
if (len > 0){
@Robin-front
Robin-front / requestIdleCallback.js
Created August 25, 2017 02:34 — forked from paullewis/requestIdleCallback.js
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Robin-front
Robin-front / randomString.js
Last active August 24, 2017 08:24
random string
function randomString(length) {
var str = '';
while(length--){
var random = Math.round(Math.random()*100)%36;
if (random < 10) {
length++;
continue;
}
str += random.toString(36);
@Robin-front
Robin-front / what-forces-layout.md
Created August 18, 2017 03:17 — 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()
@Robin-front
Robin-front / ie67891011-css-hacks.txt
Created February 17, 2017 09:42 — forked from ricardozea/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================