如何区分滚动条点击事件和滚动条拖动事件?
我需要将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以作弊,如果滚动后
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.