Jul*_*ius 5 syncfusion angular
我的主要目标是当用户向下滚动时,我需要获取当前的scrollTop 偏移量。用户可以通过鼠标单击滚动条或使用鼠标滚轮进行滚动,因此当用户这样做时,我想更新ejQuery()take()上的和skip()(或page())参数以触发 http get 并为该视图提供数据。
使用 SyncFusion 1
下面的代码是我尝试向ejTreeGrid分配一个指令,scroll通过HostListener()监视事件,但正如用户 PierreDuc 提到的,ejTreeGrid实现了它的自定义滚动条,所以默认的滚动条不会触发。PierreDuc 建议使用getScrollTopOffset方法,但我仍然需要在每次用户执行滚动操作时触发它......
指令被附加到 SyncFusion 的ejTreeGrid组件以监视scroll事件,但它不会触发。事件一切正常click- 在该子组件上触发。可能出了什么问题?
尝试过:
@HostListener('scrollY', ['$event'])
onScroll(e) {
console.log(e)
}
@HostListener('onscroll', ['$event'])
onScroll2(e) {
console.log(e)
}
@HostListener('scroll', ['$event'])
onScroll3(e) {
console.log(e)
}
@HostListener('scrollX', ['$event'])
onScroll4(e) {
console.log(e)
}
Run Code Online (Sandbox Code Playgroud)
这有效:
@HostListener('click', ['$event'])
onClick(e) {
console.log('clicked')
console.log(e)
}
Run Code Online (Sandbox Code Playgroud)
更新:
还补充道:
@HostListener('mousewheel', ['$event'])
onScroll5(e) {
console.log('mousewheel')
}
@HostListener('DOMMouseScroll', ['$event'])
onScroll6(e) {
console.log('DOMMouseScroll')
}
@HostListener('onmousewheel', ['$event'])
onScroll7(e) {
console.log('onmousewheel')
}
Run Code Online (Sandbox Code Playgroud)
并且由于某种原因,mousewheel只有当我滚动鼠标滚轮(显然)时才会被触发,但只有当滚动条位于顶部或底部时才被触发。不然就不会火。
Vis*_*dar 10
下面是工作代码:
@HostListener('document:mousewheel', ['$event'])
onDocumentMousewheelEvent(event) {
console.log('on Mouse wheel Event');
}
Run Code Online (Sandbox Code Playgroud)
小智 2
在启用虚拟化模式的 TreeGrid 中,将使用参数 requestType 作为滚动操作触发actionComplete。在这种情况下,我们可以从滚动条实例获取当前滚动顶部位置。要启用虚拟化模式,我们必须将enableVirtualization属性设置为true。
\n<pre>\n//app.component.html \nej-treegrid #TreeGridControl id="TreeGridContainer" \n//\xe2\x80\xa6 \nenableVirtualization = "true" (actionComplete) = "actionComplete($event)" > \n/ej-treegrid> \n\n//app.component.ts \nactionComplete(args){ \n if(args.requestType == "scroll"){ \n var treeObj = this.treeGrid.widget; \n var scrollTop = treeObj.getScrollElement().ejScroller("scrollTop"); \n this.scrollValue = scrollTop; \n }\n } \n </pre>\nRun Code Online (Sandbox Code Playgroud)\n我们还准备了样品供您参考,请从链接样品中找到样品
\n| 归档时间: |
|
| 查看次数: |
15689 次 |
| 最近记录: |