Skip to content

Instantly share code, notes, and snippets.

View ryanzhouff's full-sized avatar

Ryan Zhou ryanzhouff

  • Suzhou, JiangSu, China
View GitHub Profile
@ryanzhouff
ryanzhouff / free-jq.js
Last active October 17, 2018 21:35
free-jQuery
// convert NodeList to array
function makeArray(nodes) {
var array = null;
var i = 0;
var length = nodes.length;
if (!nodes) return [];
try {
// for standard
array = [].slice.call(nodes, 0);
} catch(e) { // for ie8
@ryanzhouff
ryanzhouff / easing.js
Created August 1, 2017 06:59 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@ryanzhouff
ryanzhouff / jsonp.js
Created July 17, 2017 10:01
JSONP解决跨域问题
/**
Created: 2017年7月17日 18:00:41
*/
var responseHandler ;
function JSONP(url, callback) {
if (url === "" || url === undefined) return;
if (url.indexOf("?") === -1) {
url += "?callback=responseHandler"
} else {
url += "&callback=responseHandler"
@ryanzhouff
ryanzhouff / loadscript.js
Created July 14, 2017 02:27
动态加载脚本
var loadScript = function (url, callback) {
var script = document.createElement("script"),
head = document.getElementsByTagName("head")[0];
script.type = "text/javascript";
// IE
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState === "loaded" || script.readyState === "complete") {
script.onreadystatechange = null;