我想從文檔的頂部記錄窗口的偏移量,但jQuery的滾動不起作用。將香草javascript的滾動事件監聽器工作在角?將香草javascript的滾動事件工作在angularjs
app.directive('owlCarouselItem', function($touch, $timeout, $rootScope, $window){
return {
restrict: 'C',
transclude: false,
link: function(scope, element) {
// this is the part of my directive the on scroll event is not firing
$('html, body').on('scroll', function() {
if($(this).scrollTop() == 0){
console.log($(this).scrollTop());
canSwipeDown = true;
}else{
console.log($(this).scrollTop());
canSwipeDown = false;
}
});
,你能否告訴我們你已經完成了什麼以及控制器/指令在哪裏等你正在實現這個? jQuery應該很好地檢測滾動,尤其是在AngularJS(不是Angular 2) – JosephGarrone
爲什麼你使用'restrict:C'?你是否認真地使用'owlCarouselItem'作爲評論? –