javascript - Reverse scroll direction with AngularJS -
i'm building ionic / angular app , i'm in situation reverse scroll direction on scroll input. when scroll down example area scroll move down. i'm trying accomplish when scroll down content moves , when scroll content moves down.
so possible reverse scroll direction?
this code:
<!-- home page --> <script type="text/ng-template" id=“home.html"> <ion-view ng-controller=“homecontroller" title=“home page"> <ion-content> <ion-list> <ion-item ng-repeat="message in messages track $index"> {{message}} </ion-item> <ion-list> </ion-content> </ion-view> </script>
yes, possible. @ jsfiddle.
html:
<div ng-app="scrollapp"> <scrollbox> <!-- directive --> content scrolled </scrollbox> </div>
javascript:
var app = angular.module('scrollapp', []); app.directive('scrollbox', function($window) { angular.element($window).bind('mousewheel', function(event) { event.preventdefault(); // cancel default scroll var currentposition = $window.pageyoffset; var delta = event.wheeldelta; window.scrollto(0, currentposition + delta); }); return {}; });
Comments
Post a Comment