Small helper function with no dependencies that will insert a
This file contains hidden or 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(){ | |
// Adds simple `addClass`, `removeClass`, `toggleClass` and `hasClass` functionality to Eacher DOM Collections. | |
function modifyClass(obj,act,c) { | |
if ( !c ) { return obj; } | |
var classes = c.split(' '); | |
eacher.each(classes,function(i,c){ | |
obj.each(function(){ | |
if ( this.classList ) { this.classList[act](c); } |
This file contains hidden or 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
/* | |
Title: Vanilla JavaScript to fix responsive SVGs in some versions of Safari. | |
What it does: Stops the problem I described here: http://stackoverflow.com/q/17158717/1147859 Reference URL of the issue: http://codepen.io/benfrain/full/fhyrD | |
It will work on all SVGs referenced inside objects as long as given the class .emb: | |
<object class="emb" data="img/cup.svg" type="image/svg+xml"></object> | |
And also any inline SVGs. |
This file contains hidden or 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
<ul id="scene"> | |
<li class="layer" data-plax="0.00"></li> | |
<li class="layer" data-plax="0.20"></li> | |
<li class="layer" data-plax="0.40"></li> | |
<li class="layer" data-plax="0.60"></li> | |
<li class="layer" data-plax="0.80"></li> | |
<li class="layer" data-plax="1.00"></li> | |
</ul> |
This file contains hidden or 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
<button>Click me</button> | |
<script>console.clear();</script> |
This file contains hidden or 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
<p class="desc">Cloth code adapted from <a href="https://codepen.io/dissimulate/details/eZxEBO/">Tearable Cloth v2</a> by <a href="https://codepen.io/dissimulate/" target="_blank">dissumulate</a>. Most images from <a href="http://unsplash.it" target="_blank">unsplash.it</a>.</p> |
This file contains hidden or 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
console.clear(); | |
let mesh; | |
let cloth; | |
let spacingX = 5; | |
let spacingY = 5; | |
let opts = { | |
image: 'http://brokensquare.com/Code/assets/face.png', | |
pointsX: 40, |