This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://gist.github.com/snorpey/7230329 | |
function getTransitionDuration(el){ | |
var res = 0 | |
prefix('transition-duration', function(v, pfx){ | |
duration = el.style[v] | |
if(!duration) return | |
duration = parseTime(duration) + parseTime(el.style[pfx('transition-delay')] || 0) | |
function parseTime(s){ return parseFloat(s) * (s.indexOf('ms') >- 1 ? 1 : 1000) } | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////// | |
//// The app core | |
// A simple app that inherits from Riot | |
var app = Object.create(riot) | |
// Map urls to app.routes[method](args..) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////// | |
//// Simple minimal router (works in IE9+) | |
///////////////////////////////////////////////// | |
/*** Usage ************************************** | |
//// Navigate to url | |
route('/path') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////// | |
//// Lazy object properties | |
///////////////////////////////////////////////// | |
// Sets a property that computes its value on first access | |
// (see a test below for usage example) | |
function lazy(obj, prop, fn){ | |
if(typeof prop === 'string') set(prop, fn) | |
else Object.keys(prop).forEach(function(k){ set(k, prop[k]) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////// | |
//// Minimal routing library (IE10+) | |
///////////////////////////////////////////////// | |
// Listen to url changes: | |
// route(function(param, param...){}) - will get /param/param, split as arguments | |
// Navigate to path: | |
// route.to(path) - redirect to new path | |
// route.to(path, true) - redirect to new path, replacing current url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find items in a collection | |
var _ = module.exports = {} | |
_.find = function(c, s){ return search(c, s, {one:true}) } | |
_.findIndex = function(c, s){ return search(c, s, {one:true, index:true}) } | |
_.findLast = function(c, s){ return search(c, s, {one:true, last:true}) } | |
_.findLastIndex = function(c, s){ return search(c, s, {one:true, index:true, last:true}) } | |
_.filter = function(c, s){ return search(c, s) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadFonts(url, defer){ | |
localStorage.fontUrl == url | |
? inject(localStorage.font) | |
: defer | |
? window.addEventListener('DOMContentLoaded', load) | |
: load() | |
function load(){ | |
var req = new XMLHttpRequest() |