I dealt with the same problem. For me, IE9 does not throw out a mouseup event for scrollbars. So, I checked on IE9 when you "mouseup" throws a mousemove event. So what I did is scroll the monitor and control mousemove. When the user scrolls and the mousemove event occurs, I understand it as a mouseup event. Just do this check for IE9 by running proto accessibility. The code will also work for Opera, but Opera has a mouse, and then there is no problem for me when both events happen. Here is the code, I am writing AngularJS + ZEPTO code, so get the idea and write your own code, do not wait to copy and paste this code directly:
// Global for scrolling timeout var q; // Action to do when stop scrolling var updatePosition = function() { // Put the code for stop scrolling action here } $(document).on('mousemove', function(e) { console.log('MOUSE MOVE ' + e.pageX + ',' + e.pageY); if(!('__proto__' in {})) { // for IE only, because it dont have mouseup if($scope.scrolling && $scope.mouse_down) { console.log('FAKE MOUSE UP FOR IE'); // Only simulate the mouseup if mouse is down and scrolling $scope.scrolling = false; $scope.mouse_down = false; // Update Position is the action i do when mouseup, stop scrolling updatePostition(); } } }); $(window).on('scroll', function(){ console.log('SCROLLING'); // Set the scrolling flag to true if(!$scope.scrolling) { $scope.scrolling = true; } // Stop if for some reason you disabled the scrolling monitor if(!$scope.monitor_scrolling) return; // Monitor scroll with a timeout // Update Position is the action i do when stop scrolling var speed = 200; $timeout.cancel(q); q = $timeout(updatePostition, speed); }); $(window).on('mousedown', function() { console.log('MOUSE DOWN'); // Stop monitor scrolling $scope.monitor_scroll = false; // Set that user is mouse down $scope.mouse_down = true; }); $(window).on('mouseup', function() { console.log('MOUSE UP'); // Enable scrolling monitor $scope.monitor_scroll = true; // Change mouse state $scope.mouse_down = false; // Action when stop scrolling updatePostition(); });
Struggling with this problem. My system also works for mobile devices, and I have a large horizontal scroll, which whenever the user stops scrolling, I need to find the actual element that is being used - this is viewing and centralizing this element on the screen (updatePosition). Hope this can help you. This is support for IE9 +, FF, Chorme and Opera, I'm not worried about older browsers.
Best wishes
source share