When using Fullpage.js, overflowing section / slide content will be made scrollable with Slimscroll. If you want to use addons that rely on the natural scroll event, these will fail with Slimscroll. One of the candidates breaking is Scrollreveal.js for example.
I decided to work around that, to allow animations to be triggered when elements become visible or invisible to the viewport.
You could code the viewport visibility check yourself or use the “visible” jquery plugin.
“This is a jQuery plugin which allows us to quickly check if an element is within the browsers visual viewport, regardless of the scroll position. If a user can see this element, the function will return true.” jquery-visible on Github
The idea was to extend or hook into slimscroll without touching the fullpage.js codebase. Fullpage.js wraps overflowing content within a fp-scrollable container. Slimscroll itself provides events to track your position within the scrollable area in pixels or when top / bottom have been reached.
});
});
This is just a crude and simple starting point, but should give you the basic idea. This still needs some throttling, so that its not called on every scroll position.
var currentScrollDirection = "down"; var currentScrollPosition = 0; // Top has been reached if(cPos == 0){ currentScrollDirection = "down"; } // Scrolling up or down? currentScrollDirection = "up" }else{ currentScrollDirection = "down" } // Store current position to compare on next check // Our scroll element var element = $(this); // Using the class "reveal" for all elements to track within // Loop over elements on scroll // using the visible plugin if ($(this).visible(true) ) { // add inView and direction classes $(this).addClass("inView") .removeClass("outView") .removeClass("up") .removeClass("down") .addClass(direction); }else{ // add outView class and handle other classes $(this).addClass("outView") .removeClass("up") .removeClass("down") .removeClass("inView"); } })
<div class="scrollArea"> <div id="elOne" class="reveal"> </div> <div id="elTwo" class="reveal"> </div> <div id="elThree" class="reveal"> </div> </div>
Very basic idea to get some transitions working.
.inView.down{ border-left:4px solid red; opacity: 1; animation: scaleUpDown 1.5s ease both; } .inView.up{ border-left:4px solid blue; opacity: 1; } .outView{ opacity: .6; -webkit-transition:opacity 1500ms ease-out; -moz-transition:opacity 1500ms ease-out; -o-transition:opacity 1500ms ease-out; transition:opacity 1500ms ease-out; } @keyframes scaleUpDown { from{ opacity: 0; transform: scale(0.2) rotate(30deg) translate(50%)}; to { opacity: 1; transform: scale(1.0) rotate(0deg) translate(50%)}; }
Hopefully Fullpage.js will be switching to iScroll natively in the future, as it provides far more options to handle scrollable areas. You can use iScroll now, but you have to disable the scrolling feature within Fullpage.js and call iScroll yourself. Not that difficult to do :)
There is also a WordPress Plugin that wraps Fullpage.js natively with a nice interface (WP_Fullpage) and my upcoming Visual Composer integration, which already uses iScroll :)
What are particle animations? Particle network animations in JavaScript typically involve creating visual representations of… Read More
BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More
THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More
2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More
Short look back at 2023 This has been a busy and interesting year. I am… Read More
Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More