Last active
February 29, 2024 15:42
-
-
Save Flowbaseco/0f3679e439d0c51e401c21946f51ce59 to your computer and use it in GitHub Desktop.
This file contains 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
<!-- Auto Rotate Webflow Tabs by Flowbase.co (v1.4 Updated 10/04/2023) --> | |
<script> | |
var Webflow = Webflow || []; | |
Webflow.push(function () { | |
// Fix for Safari | |
if (navigator.userAgent.includes("Safari")) { | |
document.querySelectorAll(".tab-button").forEach((t)=>(t.focus=function(){const x=window.scrollX,y=window.scrollY;const f=()=>{setTimeout(()=>window.scrollTo(x,y),1);t.removeEventListener("focus",f)};t.addEventListener("focus",f);HTMLElement.prototype.focus.apply(this,arguments)})); | |
} | |
// Start Tabs | |
var tabTimeout; | |
clearTimeout(tabTimeout); | |
tabLoop(); | |
// Connect your class names to elements. | |
function tabLoop() { | |
tabTimeout = setTimeout(function() { | |
var $next = $('.tabs-menu').children('.w--current:first').next(); | |
if($next.length) { | |
$next.click(); // user click resets timeout | |
} else { | |
$('.tab-button:first').click(); | |
} | |
}, 5000); // 5 Second Rotation | |
} | |
// Reset Loops | |
$('.tab-button').click(function() { | |
clearTimeout(tabTimeout); | |
tabLoop(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment