mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-22 23:37:53 +00:00
arrownav: avoid rude event handling for form elements #887
This commit is contained in:
parent
efa0a93fb7
commit
3a0ae52e61
1 changed files with 8 additions and 9 deletions
|
@ -782,6 +782,10 @@ function initArrowHorizontalNav(){
|
|||
var scrollEnd = 0;
|
||||
document.addEventListener('keydown', function(event){
|
||||
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
|
||||
var f = event.target.matches( formelements );
|
||||
if( f ){
|
||||
return;
|
||||
}
|
||||
if( event.which == dir_key_start ){
|
||||
if( !scrollStart && +el.scrollLeft.toFixed()*dir_scroll <= 0 ){
|
||||
prev && prev.click();
|
||||
|
@ -804,6 +808,10 @@ function initArrowHorizontalNav(){
|
|||
});
|
||||
document.addEventListener('keyup', function(event){
|
||||
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
|
||||
var f = event.target.matches( formelements );
|
||||
if( f ){
|
||||
return;
|
||||
}
|
||||
if( event.which == dir_key_start ){
|
||||
// check for false indication if keyup is delayed after navigation
|
||||
if( scrollStart == -1 ){
|
||||
|
@ -817,15 +825,6 @@ function initArrowHorizontalNav(){
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// avoid keyboard navigation for input fields
|
||||
document.querySelectorAll( formelements ).forEach( function( e ){
|
||||
e.addEventListener( 'keydown', function( event ){
|
||||
if( event.which == dir_key_start || event.which == dir_key_end ){
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initMenuScrollbar(){
|
||||
|
|
Loading…
Reference in a new issue