rigor789/vue-scrollto

Scrolling canceled on triggering scroll with keyboard

Open

#130 创建于 2019年3月19日

在 GitHub 查看
 (1 评论) (10 反应) (0 负责人)JavaScript (1,966 star) (114 fork)batch import
enhancementhelp wanted

描述

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. ???

贡献者指南