nav: fix nav on last project page and horizontal scrolling detection #452

This commit is contained in:
Sören Weber 2023-02-04 01:42:21 +01:00
parent 8f4d9f4930
commit 03c2bf52a9
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -394,10 +394,10 @@ function initArrowNav(){
} }
// button navigation // button navigation
var e = document.querySelector( 'a.nav-prev' ); var prev = document.querySelector( 'a.nav-prev' );
e && e.addEventListener( 'click', navPrev ); prev && prev.addEventListener( 'click', navPrev );
e = document.querySelector( 'a.nav-next' ); var next = document.querySelector( 'a.nav-next' );
e && e.addEventListener( 'click', navNext ); next && next.addEventListener( 'click', navNext );
// keyboard navigation // keyboard navigation
// avoid prev/next navigation if we are not at the start/end of the // avoid prev/next navigation if we are not at the start/end of the
@ -408,8 +408,8 @@ function initArrowNav(){
document.addEventListener('keydown', function(event){ document.addEventListener('keydown', function(event){
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){ if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
if( event.which == '37' ){ if( event.which == '37' ){
if( !scrollLeft && el.scrollLeft <= 0 ){ if( !scrollLeft && +el.scrollLeft.toFixed() <= 0 ){
navPrev(); prev && prev.click();
} }
else if( scrollLeft != -1 ){ else if( scrollLeft != -1 ){
clearTimeout( scrollLeft ); clearTimeout( scrollLeft );
@ -417,8 +417,8 @@ function initArrowNav(){
scrollLeft = -1; scrollLeft = -1;
} }
if( event.which == '39' ){ if( event.which == '39' ){
if( !scrollRight && el.scrollLeft + el.clientWidth >= el.scrollWidth ){ if( !scrollRight && +el.scrollLeft.toFixed() + +el.clientWidth.toFixed() >= +el.scrollWidth.toFixed() ){
navNext(); next && next.click();
} }
else if( scrollRight != -1 ){ else if( scrollRight != -1 ){
clearTimeout( scrollRight ); clearTimeout( scrollRight );