【问题标题】:Angular Equivalent of jQuery MouseWheeljQuery MouseWheel 的 Angular 等效项
【发布时间】:2016-10-28 00:12:17
【问题描述】:

有谁知道mousewheel 的等效角度是多少?

我基本上需要能够在 Angular 中执行以下操作,但找不到太多关于它的信息

$(document).bind('mousewheel', function(e) {...

我正在处理的网站上有overflow: hidden,这意味着没有滚动条并且窗口滚动不起作用。我只需要能够检测到滚动事件来触发函数。 Onscroll 仅在滚动条实际移动时起作用

感谢您的帮助

【问题讨论】:

标签: jquery angular


【解决方案1】:
@Directive({
    selector: '[wheel]'
})
class WheelDirective {

 @HostListener('wheel', ['$event']) 
  Wheel(event) {
   console.log('wheel');
  }
}

<div wheel class="wheel">..long text</div>

.wheel {
  max-height: 300px;
  overflow: scroll;
}

【讨论】:

  • 多么荒谬的语法。 Google 需要停止这种疯狂行为。
猜你喜欢
  • 2015-04-26
  • 2011-07-26
  • 2013-10-08
  • 2013-08-11
  • 2019-07-13
  • 1970-01-01
  • 2019-09-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多