rigor789/vue-scrollto

Scrolling canceled on triggering scroll with keyboard

开放

#130 创建于 2019年3月19日

 (1 条评论) (10 个反应) (0 位负责人)JavaScript (114 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (1,966 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南