mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
nav: fix nav on last project page and horizontal scrolling detection #452
This commit is contained in:
parent
8f4d9f4930
commit
03c2bf52a9
1 changed files with 8 additions and 8 deletions
|
@ -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 );
|
||||||
|
|
Loading…
Reference in a new issue