绑定'滚动'不会'我在IE 11中不工作
bind on 'scroll' doesn't work in IE 11
我有一个Angular指令,它需要对ELEMENT上的滚动事件执行某些操作(请不要在文档上说要执行此操作。这不是一个选项)。这个元素上的CSS有"overflow-y:visible",所以我现在改为"overflow:auto"进行测试。在IE 11上,我无法触发滚动事件,但在Chrome中,一切都很好。
app.directive('infiniteScroller', ['$document', function($document){
return {
restrict: 'AE',
link: function($scope, $element, $attrs){
var elm = document.querySelector('.class-for-some-div');
var elm2 = $($element).closest('.class-for-some-div');
console.log('infiniteScroller initialized, querysel, jquery', elm, elm2);
elm.onscroll = function(event) {
console.log('in bind scroll');
};
elm.addEventListener('scroll', function() {
console.log('addEventListener scroll');
},false);
// elm.attachEvent('onscroll',function() {
// console.log('attachEvent onscroll');
// }); //doesn't work on Chrome or IE
elm2.bind('DOMMouseScroll', function() {
console.log('bind DOMMouseScroll');
});
elm2.bind('wheel', function() {
console.log('bind wheel');
});
// elm2.bind('scroll', function() {
// console.log('bind scroll');
// });
}
};
}]);
正如你所看到的,我正在尝试各种各样的东西,但在IE中只有"轮子"事件控制台。其他人都没有。为什么IE不触发"滚动"事件,而只触发"轮子"活动?我只在IE控制台上看到"绑定轮子"。还对其他IE版本(9+)中的功能感兴趣。请帮忙。
我在IE中遇到了类似的问题。
看起来,当具有水平滚动的div的内容不可见时,事件就不会启动。不工作示例:
<div class="horizontal_scroller_container" style="width:500px;">
<div class="horizontal_scroller" style="height:17px;overflow:scroll;">
<div style="width: 6450px;"> </div>
</div>
</div>
工作示例:
<div class="horizontal_scroller_container" style="width:500px;">
<div class="horizontal_scroller" style="overflow:scroll;">
<div style="width: 6450px; height:1px;"> </div>
</div>
</div>
这是一把小提琴,展示了问题和解决方案:https://jsfiddle.net/1zzgnec6/3/
相关文章:
- window.onpopstate不工作;当我导航回页面时,不会发生任何事情
- .html()不会'页面更改或刷新时无法工作
- 使用几个<脚本>标签不会't工作-只调用一个脚本
- 双向绑定不会;我不在ES6工作
- Hammer.js滑动不会'单击按钮后才能工作
- onmousemove=null不会'我不在IE工作
- d3.select()在转换后不会立即工作
- 使用像素操作修改画布在某种程度上不会;我不能完全在IE9中工作
- 将图标作为参数传递不会;t工作-谷歌地图
- Dropdown不会't工作手机浏览器&Firefox
- toLocaleString()不会'无法在Safari浏览器中工作
- jQuery css"点击“;不会'更改日历中选定的月份后无法工作
- 另一个按钮内的按钮不会;不能在Firefox(Angular Material)中工作
- 拖放不会'不能使用EaselJS在chrome中工作
- 绑定'滚动'不会'我在IE 11中不工作
- 复选框的checked属性的修改不会;工作不正常
- 使输入不可聚焦,tabindex=“-1〃;不会'Don’我不能做这项工作
- Javascript在本地工作,不会在Web服务器上工作
- jquery函数不工作不会显示警报
- 使用 django-froala-editor,编辑器在管理页面中工作不会在帖子页面中工作吗?未捕获的类型错误: $(.