So here is my solution to the problem:
Elements that have the .sectrol-link class disappear or singly, depending on how you scroll.
For this method to work, you do not need to have an actual scroll bar. The solution does not track the scroll position; it is based on the scrollwheel event.
It also disappears when scrolling items.
I am sure that you can customize the solution to suit your needs.
// Constants var pxPerItem = 720; var sectorLinks = $('.sector-link'); var scrollYMax = sectorLinks.length * pxPerItem; //Fade controller variable var currentScrollY = 0; //Calculates fade value for the item based on current 'scroll' position function calculateFade(itemNo) { var relativeScroll = (currentScrollY - pxPerItem * itemNo) / pxPerItem; return Math.min(Math.max(0, relativeScroll), 1) } //Keeps the controller scroll variable within the bounds based on the amount of elements. function normalizeCurrentScroll() { currentScrollY = Math.min(Math.max(0, currentScrollY), scrollYMax); } //The actual event that controls items fade $(window).bind('mousewheel DOMMouseScroll', function(event){ var delta = event.originalEvent.wheelDelta == 0 ? event.originalEvent.detail : event.originalEvent.wheelDelta; currentScrollY -= delta; for (var i = 0; i < sectorLinks.length; i++) { $(sectorLinks[i]).fadeTo(20, calculateFade(i)); } normalizeCurrentScroll(); });
The amount of wheel spin needed to fade out or disappear is controlled by the variable 'pxPerItem'. If you want to place such a thing below on your page, you will have to set up the scrollYMax variable and calculate the FadeFunction to match your height.
Fiddle: https://jsfiddle.net/gLtgj54s/18/
Mokona modoki
source share