Hey guys this is rather urgent. I would really appreciate it if anyone could help me out with this, I have auto-rotate tabs (which is achieved with the code listed below) the thing is that they start to change when the page loads, I am looking to make their ether to start the auto-rotate function when they are in view or possibly to trigger a click event on the first tab when they are in view so it looks like they start from the first tab.
<script>
var load = true;
$(window).scroll(function() {
var divTop = $('.hit-scroll').offset().top,
divHeight = $('.hit-scroll').outerHeight(),
wHeight = $(window).height(),
windowScrTp = $(this).scrollTop();
if (windowScrTp > (divTop+divHeight-wHeight)){
if(load){
load = false;
$('body').find('.show-more button').trigger('click');
}
}
});
var Webflow = Webflow || [];
Webflow.push(function () {
var tabTimeout;
clearTimeout(tabTimeout);
tabLoop();
function tabLoop() {
tabTimeout = setTimeout(function() {
var $next = $('.tabs-list').children('.w--current:first').next();
if($next.length) {
if ($(".menu-button").hasClass("w--open")) {
tabLoop();
}else{
$next.removeAttr("href").click();
}
} else {
if ($(".menu-button").hasClass("w--open")){
tabLoop();
}else{
$('.tab-text-box:first').removeAttr("href").click();
}
}
}, 20000); // 20 seconds
}
$('.tab-text-box').click(function() {
clearTimeout(tabTimeout);
tabLoop();
});
});
// Play animation when scrolled into view
$('#tabs-wrapper').on('inview', function(event, isInView) {
if (isInView) {
// Put the play below this line
tabLoop();
} else {
}
});
</script>
<script>
var Webflow = Webflow || [];
Webflow.push(function() {
window.addEventListener('resize', function() {
window.Webflow.require("lottie").lottie.resize();
});
});
</script>
Here is my site Read-Only: https://preview.webflow.com/preview/cycube-io?utm_medium=preview_link&utm_source=designer&utm_content=cycube-io&preview=aa8e74053ed1cd92abd62e1d3459ae95&pageId=62b729d919e99be0bc3f5ec9&workflow=preview
and here is the live site live site