Slightly variation of http://tympanus.net/Tutorials/CSSButtonsPseudoElements/index4.html
A Pen by Peter Broschwitz on CodePen.
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Factory Pattern</title> | |
<meta name="description" content="A framework for easily creating beautiful presentations using HTML"> | |
<meta name="author" content="Hakim El Hattab"> |
onScroll(): () => void { | |
var last, timeout, threshold = 100; | |
return () => { | |
var now = Date.now(); | |
if (last && now < last + threshold) { | |
window.clearTimeout(timeout); | |
timeout = window.setTimeout(function () { | |
last = now; |
// Custom event listening | |
$(document).on('historyslider:initvideo', function (event) { | |
var args: any = [].slice.call(arguments), | |
players = args.length > 1 ? args[1] : $(); | |
_this.initVideo(players); | |
}); |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Classical Pattern - Code Reuse Pattern</title> | |
<meta name="description" content="A framework for easily creating beautiful presentations using HTML"> | |
<meta name="author" content="Hakim El Hattab"> |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
/** | |
* Test for rebeccapurple, honoring Eric Meyer’s Daughter, Rebecca. | |
* Currently works in WebKit nightlies, other implementations soon to follow. | |
*/ | |
background: red; | |
background: rebeccapurple; | |
display: flex; |
function aContainsB (a, b) { | |
return a.indexOf(b) >= 0; | |
} | |
var philosophers = "Aquinas, Maimonedes, and Avicenna"; | |
var me = "Joshua"; | |
function printPhilosopherStatus (person) { | |
if (aContainsB(philosophers, person)) { | |
console.log(person + " is a philosopher."); |
/** | |
* This is similar to http://php.net/manual/en/function.array-reduce.php but returns | |
* the return from the callback immediately when it is 'truthy'. The callback also | |
* is being passed the 'key' in addition to just the 'value'. So this is basically | |
* some sort of more flexible array_reduce, array_filter and array_search | |
*/ | |
function array_find($array, $callback) { | |
foreach ($array as $key => $value) { | |
$result = $callback($value, $key); | |
if ($result) { |