rigor789/vue-scrollto

Scrolling canceled on triggering scroll with keyboard

Open

#130 opened on Mar 19, 2019

View on GitHub
 (1 comment) (10 reactions) (0 assignees)JavaScript (1,966 stars) (114 forks)batch import
enhancementhelp wanted

Description

With either:

<a href="#" v-scroll-to="'#anchor'">Scroll</a>

or triggering scroll programatically from click event:

<a href="#" @click="VueScrollTo.scrollTo('#anchro')">Scroll</a>

If the scroll is triggered using keyboard (enter button), the scroll will be canceled right after it started. This is because keyup event cancels scroll.

I know I can set cancelable: false but that's not ideal as it makes sense for some keys to cancel scroll (arrows, spacebar, escape).

Options for resolving this: a. Check only for specific buttons that should be able to cancel. b. Don't cancel if keyup matches the same button that triggered keydown (might be tricky as it's click event that triggers scroll typically). c. Maybe trigger scroll from delay ($nextTick?) so that it triggers after keyup event. d. ???

Contributor guide