I followed a popular Timothy Ricks tutorial to get a page transition going, and had it working for a while. I decided to change it and remove the lottie, but I can’t seem to get it working. Every now and then I’ll make a change that makes either the in/out animation work, but not both. Any Help?
<style>
body .transition {display: block}
.w-editor .transition {display: none;}
.no-scroll-transition {overflow: hidden; position: relative;}
</style>
<script>
let transitionTrigger = $(".transition-trigger");
let introDurationMS = 1500;
let exitDurationMS = 1700;
let excludedClass = "no-transition";
// On Page Load
let transitionTrigger = $(".transition-trigger");
let introDurationMS = 0;
let exitDurationMS = 1200;
let excludedClass = "no-transition";
// On Page Load
if (transitionTrigger.length > 0) {
transitionTrigger.click();
$("body").addClass("no-scroll-transition");
setTimeout(() => {$("body").removeClass("no-scroll-transition");}, introDurationMS);
}
// On Link Click
$("a").on("click", function (e) {
if ($(this).prop("hostname") == window.location.host && $(this).attr("href").indexOf("#") === -1 &&
!$(this).hasClass(excludedClass) && $(this).attr("target") !== "_blank" && transitionTrigger.length > 0) {
e.preventDefault();
$("body").addClass("no-scroll-transition");
let transitionURL = $(this).attr("href");
transitionTrigger.click();
setTimeout(function () {window.location = transitionURL;}, exitDurationMS);
}
});
// On Back Button Tap
window.onpageshow = function(event) {if (event.persisted) {window.location.reload()}};
// Hide Transition on Window Width Resize
setTimeout(() => {$(window).on("resize", function () {
setTimeout(() => {$(".transition").css("display", "none");}, 50);});
}, introDurationMS);
</script>
Here is my site Read-Only: Webflow - Jacob Johnson Arts