Skip to content

Instantly share code, notes, and snippets.

View genoma's full-sized avatar

Alessandro Vioni genoma

View GitHub Profile
@genoma
genoma / supportTransitions
Last active December 24, 2015 21:59
Check browser support for CSS3 transitions
supportsTransitions = ->
docBody = document.body or document.documentElement
styles = docBody.style
prop = "transition"
return true if typeof styles[prop] is "string"
# Tests for vendor specific prop
vendor = ["Moz", "Webkit", "Khtml", "O", "ms"]
prop = prop.charAt(0).toUpperCase() + prop.substr(1)
i = undefined
@genoma
genoma / slider-responsive.coffee
Created September 20, 2013 13:36
Slider Responsive
# Reference jQuery
$ = jQuery
# Adds plugin object to jQuery
$.fn.extend
# Change pluginName to your plugin's name.
responsiveSlider: (options) ->
# Default settings
settings =
debug: false
@genoma
genoma / jquery-plugin.coffee
Last active December 23, 2015 10:39
Basic jquery plugin template for coffeescript
# Reference jQuery
$ = jQuery
# Adds plugin object to jQuery
$.fn.extend
# Change pluginName to your plugin's name.
pluginName: (options) ->
# Default settings
settings =
option1: true
browser = ->
val = navigator.userAgent.toLowerCase()
if val.indexOf("firefox") > -1
browser = 'firefox'
else if val.indexOf("chrome") > -1
browser = 'chrome'
else if val.indexOf("opera") > -1
browser = 'opera'
else if val.indexOf("msie") > -1
browser = 'ms'
// http://stackoverflow.com/questions/2450954/how-to-randomize-a-javascript-array
// SHUFFLE ARRAY
function shuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
(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;