Skip to content

Instantly share code, notes, and snippets.

@nevergiveup-j
nevergiveup-j / gist:3be68594eba85237941c
Created December 14, 2015 12:11
_requestAnimationFrame
this._requestAnimationFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();
@nevergiveup-j
nevergiveup-j / onerror
Last active June 12, 2018 06:09
前端代码异常日志收集与监控
/**
* @param {String} msg 错误信息
* @param {String} url 出错的文件
* @param {Long} line 出错代码的行号
* @param {Long} col 出错代码的列号
* @param {Object} error 错误的详细信息,Anything
*/
window.onerror = function(msg,url,line,col,error){
//没有URL不上报!上报也不知道错误
if (msg != "Script error." && !url){
@nevergiveup-j
nevergiveup-j / arrayLottery
Last active August 29, 2015 14:04
jQuery 数组随机抽奖
/**
* @Description: jQuery 数组随机抽奖
* @Author: wangjun
* @Update: 2014-07-22 17:00
* @Github URL: https://github.com/nevergiveup-j
*/
!function($){
"use strict";
@nevergiveup-j
nevergiveup-j / jQuery.plugin
Last active August 29, 2015 14:03
AMD兼容的jQuery插件
;(function (factory) {
if (typeof define === "function" && define.amd) {
// AMD模式
define([ "jquery" ], factory);
} else {
// 全局模式
factory(jQuery);
}
}(function ($) {
"use strict";
@nevergiveup-j
nevergiveup-j / fullScreen.js
Last active August 29, 2015 14:02
HTML5 全屏API
/*
Native FullScreen JavaScript API
CopyRight: Johndyer, http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
-------------
Assumes Mozilla naming conventions instead of W3C for now
*/
(function() {
var
fullScreenApi = {
supportsFullScreen: false,