start new version of website
This commit is contained in:
0
newVersion/js/index.js
Normal file
0
newVersion/js/index.js
Normal file
25
newVersion/js/scrolling.js
Normal file
25
newVersion/js/scrolling.js
Normal file
@@ -0,0 +1,25 @@
|
||||
$( document ).ready( function () {
|
||||
|
||||
document.addEventListener( 'scroll', scrolled );
|
||||
|
||||
let revealables = document.querySelectorAll( '.reveal' );
|
||||
|
||||
let currentlyShowing = Math.floor( window.scrollY / ( window.innerHeight / revealables.length + 50 ) );
|
||||
|
||||
|
||||
for ( let i = 0; i < currentlyShowing; i++ ) {
|
||||
if ( i < parseInt( revealables.length ) ) {
|
||||
revealables[ i ].classList.add( 'active' );
|
||||
}
|
||||
}
|
||||
|
||||
function scrolled() {
|
||||
let regPos = Math.floor( window.scrollY / ( window.innerHeight / revealables.length + 50 ) );
|
||||
if ( regPos < currentlyShowing && regPos < parseInt( revealables.length ) ) {
|
||||
revealables[ regPos ].classList.remove( 'active' );
|
||||
} else if ( regPos > currentlyShowing && regPos < parseInt( revealables.length ) + 1 ) {
|
||||
revealables[ currentlyShowing ].classList.add( 'active' );
|
||||
}
|
||||
currentlyShowing = regPos;
|
||||
}
|
||||
} );
|
||||
Reference in New Issue
Block a user