Reverse Scroll Direction With AngularJS
I'm building an Ionic / Angular app and I'm in a situation that I would like to reverse the scroll direction on scroll input. So normally when you scroll down for example the area
Solution 1:
Yes, it is possible. Look at this jsFiddle.
HTML:
<div ng-app="scrollApp">
<scrollbox> <!-- my directive -->
Content to be scrolled
</scrollbox>
</div>
JavaScript:
var app = angular.module('scrollApp', []);
app.directive('scrollbox', function($window) {
angular.element($window).bind('mousewheel', function(event) {
event.preventDefault(); // cancel the default scroll
var currentPosition = $window.pageYOffset;
var delta = event.wheelDelta;
window.scrollTo(0, currentPosition + delta);
});
return {};
});
Post a Comment for "Reverse Scroll Direction With AngularJS"