Skip to content

Instantly share code, notes, and snippets.

Avatar

Katsumasa Tamanaha kTmnh

View GitHub Profile
@kTmnh
kTmnh / gist:5525045
Created May 6, 2013
drag and drop test
View gist:5525045
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#dropTarget {
width: 100%;
height: 200px;
border: 1px dashed #000000;
@kTmnh
kTmnh / gist:4661261
Last active Dec 11, 2015
iOS 6 timer bug test sample. Apparently, Apple fixed the problem on iOS 6.1.
View gist:4661261
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script>
window.onload = function() {
var element = document.getElementById("test");
var result = document.getElementById("result");
var count = 0;
@kTmnh
kTmnh / javascript_techniques.js
Last active May 13, 2016
JavaScript techniques including bitwise operator replacement techniques, shortcuts, etc.
View javascript_techniques.js
var PI = Math.PI;
//Faster replacement for Math object methods.
Math.round(PI) === PI + (PI < 0 ? -0.5 : +0.5) >> 0;
Math.ceil(PI) === PI + (PI < 0 ? -1 : 0) >> 0;
Math.floor(PI) === PI + (PI < 0 ? -1 : 0) >> 0;
//Conditional operator is faster than Math object methods.
Math.max(a, b) === (a > b) ? a : b;
Math.min(a, b) === (a < b) ? a : b;
@kTmnh
kTmnh / ios6-timers.js
Last active Dec 12, 2019 — forked from ronkorving/ios6-timers.js
iOS6 webkit timer bug workaround
View ios6-timers.js
(function (window) {
// This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6.
// iOS6 suffers from a bug that kills timers that are created while a page is scrolling.
// This library fixes that problem by recreating timers after scrolling finishes (with interval correction).
// This code is free to use by anyone (MIT, blabla).
// Original Author: rkorving@wizcorp.jp
var timeouts = {};
var intervals = {};
var orgSetTimeout = window.setTimeout;
var orgSetInterval = window.setInterval;
You can’t perform that action at this time.