Skip to content

Instantly share code, notes, and snippets.

@rotcl
Created April 4, 2019 18:12
Show Gist options
  • Save rotcl/7d5f0ff2ec06b20310a8e20544ef213e to your computer and use it in GitHub Desktop.
Save rotcl/7d5f0ff2ec06b20310a8e20544ef213e to your computer and use it in GitHub Desktop.
Shopify - Emoji Rain
{% comment %}
@rotcl
{% endcomment %}
<div id="fll">
<div id="cnt">
<div id="anmt">
</div>
</div>
</div>
<style>
#cnt {
left: 0px;
top: -100px;
height: calc(100vh + 100px);
overflow: hidden;
position: relative;
}
#anmt{
margin: 0 auto;
width: 20px;
overflow: visible;
position: relative;
}
#fll{
overflow: hidden;
height: 100vh;
width: 100%;
position: fixed;
}
#fll span{
z-index: 9999999;
}
</style>
<script>
var container = document.getElementById('anmt');
var emoji = ['🌽', 'πŸ‡', '🍌', 'πŸ’', 'πŸ•', '🍷', '🍭', 'πŸ’–', 'πŸ’©', '🐷', '🐸', '🐳', 'πŸŽƒ', '🎾', '🌈', '🍦', 'πŸ’', 'πŸ”₯', '😁', '😱', '🌴', 'πŸ‘', 'πŸ’ƒ'];
var circles = [];
for (var i = 0; i < 15; i++) {
addCircle(i * 150, [10 + 0, 300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 + 0, -300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 - 200, -300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 + 200, 300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 - 400, -300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 + 400, 300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 - 600, -300], emoji[Math.floor(Math.random() * emoji.length)]);
addCircle(i * 150, [10 + 600, 300], emoji[Math.floor(Math.random() * emoji.length)]);
}
{{ section.settings.e1 }}
function addCircle(delay, range, color) {
setTimeout(function() {
var c = new Circle(range[0] + Math.random() * range[1], 80 + Math.random() * 4, color, {
x: -0.15 + Math.random() * 0.3,
y: 1 + Math.random() * 1
}, range);
circles.push(c);
}, delay);
}
function Circle(x, y, c, v, range) {
var _this = this;
this.x = x;
this.y = y;
this.color = c;
this.v = v;
this.range = range;
this.element = document.createElement('span');
/*this.element.style.display = 'block';*/
this.element.style.opacity = 0;
this.element.style.position = 'absolute';
this.element.style.fontSize = '26px';
this.element.style.color = 'hsl('+(Math.random()*360|0)+',80%,50%)';
this.element.innerHTML = c;
container.appendChild(this.element);
this.update = function() {
if (_this.y > 800) {
_this.y = 80 + Math.random() * 4;
_this.x = _this.range[0] + Math.random() * _this.range[1];
}
_this.y += _this.v.y;
_this.x += _this.v.x;
this.element.style.opacity = 1;
this.element.style.transform = 'translate3d(' + _this.x + 'px, ' + _this.y + 'px, 0px)';
this.element.style.webkitTransform = 'translate3d(' + _this.x + 'px, ' + _this.y + 'px, 0px)';
this.element.style.mozTransform = 'translate3d(' + _this.x + 'px, ' + _this.y + 'px, 0px)';
};
}
function animate() {
for (var i in circles) {
circles[i].update();
}
requestAnimationFrame(animate);
}
animate();
</script>
{% schema %}
{
"name": "Emoji Rain",
"class": "er",
"settings": [
{
"type": "header",
"content": "Static"
}
],
"presets": [{
"name": "Emoji Rain",
"category": "Custom"
}]
}
{% endschema %}
@rotcl
Copy link
Author

rotcl commented Apr 4, 2019

eCommerce - ⚑️ Shopify ⚑️

Agregar section emoji-rain.liquid
Los emojis se pueden editar en la secciΓ³n <script> que aparecen como var = 'x', 'y', 'z'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment