如何区分滚动条点击事件和滚动条拖动事件?

发布于 2024-08-29 14:11:09 字数 356 浏览 4 评论 0原文

我需要将 EXT-GWT 网格滚动一些自定义量,而不是默认的 1-2 行。由于我找不到任何允许我执行此操作的参数,因此我重写了事件处理程序以捕获滚动或鼠标滚轮事件。在任何此类事件中,我只需以编程方式将滚动条沿同一方向进一步移动所需的量,并保留一个标志以确保它不会进入无限循环。

但是,当用户使用滚动器滚动网格时,此技术会失败。具体来说,当我将滚动条从某个位置拖动到滚动轨道的顶部时,网格中显示的行不是网格中最上面的行,而是下面的一些行。我想,如果我能够区分由向上滚动和向下滚动按钮生成的事件以及由滚动条拖动生成的事件,我就可以单独处理它们并纠正问题。

有什么办法可以做到这一点吗?或者有没有一种方法可以指定滚动条一步滚动的量?

谢谢
-萨米尔

I need to scroll an EXT-GWT grid by some custom amount instead of the default 1-2 rows. Since I couldn't find any parameter that let me do this, I overrode the event handler to capture scroll or mousewheel events. On any such event, I just programmatically move the scroller further by the required amount in the same direction, keeping a flag to ensure that it doesn't go into an infinite loop.

However, this technique fails when the user scrolls the grid with the scroller. Specifically, when I drag the scroller from some position to the top of the scroll track, the rows displayed in the grid are not the topmost rows in the grid but some rows further down. I figured that if I could differentiate between the events generated by the scroll-up and scroll-down buttons and those generated by scroller drag, I could handle them separately and rectify the issue.

Any way this could be done? Or is there a way to specify the amount by which a scrollbar should scroll in one step?

Thanks
-Sameer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱纠缠 2024-09-05 14:11:09

你可以作弊,如果滚动后 scrollTop 为 0,则直接转到开头。有点难看,但如果它是唯一不起作用的情况,将会解决该特定情况。

You could cheat, and if after scrolling scrollTop is 0, just go to the beginning. A bit ugly, but will solve that specific case, if it is the only one not working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文