Free javascript Hosting


mobile.js

Uploaded on Oct 21 2021 05:28 by ethanhan.mr.051992

$(function () {
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}

var scrollTrigger = function (trigger, callback, offset) {
var Scroller = function () {
this.trigger = trigger;
this.offset = offset || 0;
this.top = this.trigger.getBoundingClientRect().top
this.scrollHandler = function (e) {
var offset = 0;
offset = this.offset;
var doc = document.documentElement;
if (offset > this.trigger.getBoundingClientRect().top - window.innerHeight) {
window.removeEventListener('scroll', this.scrollHandler);
window.removeEventListener('resize', this.scrollHandler);
callback && callback(e);
}
}.bind(this);
window.addEventListener('scroll', this.scrollHandler);
window.addEventListener('resize', this.scrollHandler);
}
var scroller = new Scroller();
scroller.scrollHandler();
return scroller;
}

function showPops () {
$('.pop_svg').each(function (svg) {
$(this).find('circle').each(function (i, circle) {
setTimeout(function () {
$(circle).removeClass('is-hide')
}, getRandomInt(0, 2000))
})
})
}

$('.pop_svg').each(function (svg) {
$(this).find('circle').each(function () {
var cx = $(this).attr('cx'),
cy = $(this).attr('cy')
$(this).attr('transform-origin', cx + 'px ' + cy + 'px')
})
})

scrollTrigger(document.getElementById('visual01_trigger'), function () {
$('#visual01_trigger').addClass('is-active');
setTimeout(function () {
showPops()
}, 1000)
}, -400)

scrollTrigger(document.getElementById('visual03_trigger'), function () {
$('#infinityloop').addClass('is-active');
}, -100)

})

Back to list