add more pages + fix bugs

This commit is contained in:
2023-05-19 20:36:23 +02:00
parent 7a86ec0de2
commit 5f69d25662
10 changed files with 356 additions and 145 deletions

View File

@@ -7,7 +7,7 @@ $( document ).ready( function () {
let revealables = document.querySelectorAll( '.reveal' );
let heights = $( document ).height() / ( revealables.length + 1 );
let currentlyShowing = Math.round( window.scrollY / heights );
let currentlyShowing = Math.round( window.scrollY / heights ) < revealables.length + 1 ? Math.round( window.scrollY / heights ) : revealables.length;
for ( let i = 0; i < currentlyShowing; i++ ) {
if ( i < parseInt( revealables.length ) ) {
@@ -17,7 +17,7 @@ $( document ).ready( function () {
trackProgress();
let timeout = setTimeout( showScrollHint, 5000 );
let timeout = setTimeout( showScrollHint, 3500 );
if ( currentlyShowing >= revealables.length ) {
clearTimeout( timeout );
@@ -27,30 +27,30 @@ $( document ).ready( function () {
if ( sessionStorage.getItem( 'menuOpen' ) == 'false' ) {
$( '#scroll-hint' ).fadeIn( 300 );
} else {
timeout = setTimeout( showScrollHint, 10000 );
timeout = setTimeout( showScrollHint, 7000 );
}
}
function scrolled() {
heights = $( document ).height() / ( revealables.length + 1 );
let regPos = Math.round( window.scrollY / heights );
if ( regPos < currentlyShowing && regPos < parseInt( revealables.length ) ) {
revealables[ regPos ].classList.remove( 'active' );
if ( regPos != currentlyShowing && regPos < revealables.length + 1 ) {
for ( let i = 0; i < regPos + 1; i++ ) {
$( `#step-${i + 1}` ).addClass( 'active' );
}
for ( let i = regPos + 1; i < revealables.length + 1; i++ ) {
$( `#step-${i + 1}` ).removeClass( 'active' );
}
clearTimeout( timeout );
$( '#scroll-hint' ).fadeOut( 300 );
if ( regPos < revealables.length ) {
timeout = setTimeout( showScrollHint, 10000 );
}
} else if ( regPos > currentlyShowing && regPos < parseInt( revealables.length ) + 1 ) {
revealables[ currentlyShowing ].classList.add( 'active' );
clearTimeout( timeout );
$( '#scroll-hint' ).fadeOut( 300 );
if ( regPos < revealables.length ) {
timeout = setTimeout( showScrollHint, 10000 );
timeout = setTimeout( showScrollHint, 7000 );
}
currentlyShowing = regPos;
trackProgress();
}
currentlyShowing = regPos;
trackProgress();
}
function trackProgress () {
@@ -61,13 +61,10 @@ $( document ).ready( function () {
$( '.progress-item' ).click( function () {
let future = parseInt( $( this ).attr( 'id' ).substring( 4 ) ) - 1;
for ( let i = 0; i < future + 1; i++ ) {
$( `#step${i + 1}` ).html( `radio_button_checked` );
$( `#step-${i + 1}` ).addClass( 'active' );
}
for ( let i = future + 1; i < revealables.length + 1; i++ ) {
console.log( i + 1 );
$( `#step${i + 1}` ).html( `radio_button_unchecked` );
$( `#step-${i + 1}` ).removeClass( 'active' );
}
currentlyShowing = future;