Thank you for purchasing!
Watch the tutorial
<script src="<https://cdnjs.cloudflare.com/ajax/libs/protonet-jquery.inview/1.1.2/jquery.inview.min.js>"></script>
<script>
// © Code by T.RICKS, <https://www.tricksdesign.com/>
// Copyright 2020, T.RICKS, All rights reserved.
// You have the license to use this code in your projects but not to redistribute it to others
var tricksnum = $('#trickscount').text();
var tricksleft = +tricksnum;
var tricksleft2 = +tricksnum;
var tricksRefresh;
var tricksTimer;
var tricksTime = tricksleft * 1000;
var tricksNext = $(".tricksitem").find(".w--current").parent().next();
if (tricksNext.length > 0) {
tricksNext.addClass('trickscurrent');
} else {
$(".tricksitem").first().addClass('trickscurrent');
}
$(".trickscurrent").siblings().remove();
var tricksNewLink = $(".trickscurrent a").attr('href');
function tricksCount() {
tricksTimer = setInterval(function(){
tricksleft--;
document.getElementById("trickscount").textContent = tricksleft;
if(tricksleft <= 0)
clearInterval(tricksTimer);
},1000);
}
function tricksPage() {
// Go to next page after x seconds
tricksRefresh = window.setTimeout(function () {
location.href = tricksNewLink;
}, tricksTime);
}
function stopTricksCount() {
clearTimeout(tricksTimer);
}
function stopTricksPage() {
clearTimeout(tricksRefresh);
}
$('#tricksnext').on('inview', function(event, isInView) {
if (isInView) {
tricksleft = tricksleft2;
tricksCount();
tricksPage();
} else {
stopTricksCount();
stopTricksPage();
document.getElementById("trickscount").textContent = tricksleft2;
}
});
// Number with #trickscount
// Section with #tricksnext
// Collection Item with .tricksitem
</script>