Skip to content

Instantly share code, notes, and snippets.

@ethertank
ethertank / rAF.js
Last active September 30, 2015 17:38 — forked from paulirish/rAF.js
requestAnimationFrame / cancelAnimationFrame
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@ethertank
ethertank / addClass.js
Created April 2, 2012 20:03 — forked from ryan-blunden/addClass.js
addClass()
function addClass(elem, newClassName) {
var className, classes, classesLength;
if(typeof elem === 'string') { elem = document.getElementById(elem); }
if(elem === null || elem.nodeType !== 1 || typeof newClassName !== 'string') { return null; }
className = elem.className;
classes = newClassName.split(' '),
classIndex = classes.length;
/*jshint multistr: true */
// 全ての艦名 (改造艦は含まない)
var allKanmusu =
"長門, 陸奥, 伊勢, 日向, 雪風,\
赤城, 加賀, 蒼龍, 飛龍, 島風,\
吹雪, 白雪, 初雪, 深雪, 叢雲,\
磯波, 綾波, 敷波, 大井, 北上,\
金剛, 比叡, 榛名, 霧島, 鳳翔,\
function f (min, max, length) {
var arr = [],
i = 0;
for (; i < length; i++) {
arr.push(
i % (max - min + 1) + min
);
}