Skip to content

Instantly share code, notes, and snippets.

@whatifhappen
whatifhappen / vscode-file-exclude-except
Created September 24, 2021 08:48
exclude node_modual except ! condition
# https://github.com/microsoft/vscode/issues/869
# exclude node_modual except start with @
**/node_modules/[!@]**
@whatifhappen
whatifhappen / rAF
Created June 23, 2015 03:26
requestAnimationFrame on Mobile
//more detail on https://gist.github.com/paulirish/1579671
rAF = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
@whatifhappen
whatifhappen / webkit-mask
Last active August 29, 2015 14:21
fixed the overflow:hidden failed on parent element when child element contain a transform
overflow: hidden;
transform: translateZ(0);
-webkit-mask-image: -webkit-radial-gradient(circle, white, black);
backface-visibility: hidden;
perspective: 1000;
@whatifhappen
whatifhappen / on_page_load.js
Last active August 29, 2015 14:13
On page Load Code snippet from MDN
/**
* on Page Load code snippet from:
* https://developer.mozilla.org/en-US/Add-ons/Code_snippets/On_page_load
*/
window.addEventListener("load", function load(event) {
window.removeEventListener("load", load, false); //remove listener, no longer needed
myExtension.init();
}, false);
{
"name": "Gulp-workflow",
"version": "0.0.1",
"description": "gulp workflow for web development",
"main": "index.html",
"author": "R.Ten",
"license": "",
"devDependencies": {
"autoprefixer": "^5.1.0",
"autoprefixer-core": "^5.1.5",
@whatifhappen
whatifhappen / gulpfile.js
Last active August 29, 2015 14:12
gulp dev environment with js,css,html,img minify, less compressor, spritesmith, browser-sync etc.
// 引入 gulp
var gulp = require('gulp');
//路径
var src = './',
dist = './dist/';
var paths = {
js: src + '**/*.js',
images: src + '**/*.+(png|jpg|gif)',
@whatifhappen
whatifhappen / getSupportedPropertyName.js
Created December 26, 2014 02:54
getSupportedPropertyName
(function(){
//http://www.kirupa.com/html5/animating_movement_smoothly_using_css.htm
var getSupportedPropertyName = function(properties) {
for (var i = 0, len = properties.length; i < len; i++) {
if (typeof document.body.style[properties[i]] != 'undefined') {
return properties[i];
}
}
return null;
@whatifhappen
whatifhappen / simple gesture
Created November 12, 2014 06:37
simple gesture
/*需含有
zepto[http: //zeptojs.com/] 或 jquery [http://jquery.com/] 或 项目前端模板 js/zepto.js js/jquery-vx.js
创建私有空间 事件判断
*/
//APP.noop = function(){};
//手势
/**
* @param {Object} obj
* @param {Zepto|Jquery} obj.$area 移动区的外层,移动区的范围
@whatifhappen
whatifhappen / JavaScript cross domain access
Last active August 29, 2015 14:08
javascript cross domain access
JavaScript跨域
1. 单向通信 :
可通过简单的新建image, script等元素,通过给src赋值定向到目标url, 可实现跨域请求
例如
html : <button type="button">跨域通信</button>
js:
<script>
var button = document.getElementsByTagName('button')[0];
button.addEventListener('click', function() {