我可以在滚动事件中获得鼠标位置吗?
如果我有代码:
angular.element($window).bind("scroll", function() {
console.log("scroll");
// mouse position (x,y) ?
});
答案 0 :(得分:0)
angular.element($window).bind("scroll", function(event) {
console.log("scroll");
console.log(event.clientX, event.clientY); //relative to window
console.log(event.pageX, event.pageY); //relative to window
});
答案 1 :(得分:0)
您可以使用
angular.element($window).bind("scroll", function(event) {
console.log("scroll");
var domElem = event.target;
var nbPXFromTop = domElem.scrollTop; //nb of pixel from the top
var nbPxFromLeft = domElem.scrollLeft;
});