@@ -668,7 +668,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
668
668
669
669
scrollBottomOffsetToTop = container . getBoundingClientRect ( ) . bottom ;
670
670
//distance from top of focused element to the bottom of the scroll view
671
- var elementTopOffsetToScrollBottom = e . detail . elementTop - scrollBottomOffsetToTop ;
671
+ var elementTopOffsetToScrollBottom = e . detail . elementTop - scrollBottomOffsetToTop ;
672
672
673
673
var scrollTop = elementTopOffsetToScrollBottom + scrollMidpointOffset ;
674
674
ionic . tap . cloneFocusedInput ( container , self ) ;
@@ -807,55 +807,82 @@ ionic.views.Scroll = ionic.views.View.inherit({
807
807
// Mouse Events
808
808
var mousedown = false ;
809
809
810
- container . addEventListener ( "mousedown" , function ( e ) {
810
+ self . mouseDown = function ( e ) {
811
811
if ( ionic . tap . ignoreScrollStart ( e ) || e . target . tagName === 'SELECT' ) {
812
812
return ;
813
813
}
814
814
self . doTouchStart ( getEventTouches ( e ) , e . timeStamp ) ;
815
815
816
816
e . preventDefault ( ) ;
817
817
mousedown = true ;
818
- } , false ) ;
818
+ } ;
819
819
820
- document . addEventListener ( "mousemove" , function ( e ) {
820
+ self . mouseMove = function ( e ) {
821
821
if ( ! mousedown || e . defaultPrevented ) {
822
822
return ;
823
823
}
824
824
825
825
self . doTouchMove ( getEventTouches ( e ) , e . timeStamp ) ;
826
826
827
827
mousedown = true ;
828
- } , false ) ;
828
+ } ;
829
829
830
- document . addEventListener ( "mouseup" , function ( e ) {
830
+ self . mouseUp = function ( e ) {
831
831
if ( ! mousedown ) {
832
832
return ;
833
833
}
834
834
835
835
self . doTouchEnd ( e . timeStamp ) ;
836
836
837
837
mousedown = false ;
838
- } , false ) ;
839
-
840
- var wheelShowBarFn = ionic . debounce ( function ( ) {
841
- self . __fadeScrollbars ( 'in' ) ;
842
- } , 500 , true ) ;
838
+ } ;
843
839
844
- var wheelHideBarFn = ionic . debounce ( function ( ) {
845
- self . __fadeScrollbars ( 'out' ) ;
846
- } , 100 , false ) ;
840
+ self . mouseWheel = ionic . animationFrameThrottle ( function ( e ) {
841
+ if ( ionic . DomUtil . elementHasParent ( e . target , self . __container ) ) {
842
+ self . hintResize ( ) ;
843
+ self . scrollBy (
844
+ e . wheelDeltaX / self . options . wheelDampen ,
845
+ - e . wheelDeltaY / self . options . wheelDampen
846
+ ) ;
847
+ self . __fadeScrollbars ( 'in' ) ;
848
+ clearTimeout ( self . __wheelHideBarTimeout ) ;
849
+ self . __wheelHideBarTimeout = setTimeout ( function ( ) {
850
+ self . __fadeScrollbars ( 'out' ) ;
851
+ } , 100 ) ;
852
+ }
853
+ } ) ;
847
854
848
- //For Firefox
849
- document . addEventListener ( 'mousewheel' , onMouseWheel ) ;
850
- }
851
- function onMouseWheel ( e ) {
852
- self . hintResize ( ) ;
853
- wheelShowBarFn ( ) ;
854
- self . scrollBy ( e . wheelDeltaX / self . options . wheelDampen , - e . wheelDeltaY / self . options . wheelDampen ) ;
855
- wheelHideBarFn ( ) ;
855
+ container . addEventListener ( "mousedown" , self . mouseDown , false ) ;
856
+ document . addEventListener ( "mousemove" , self . mouseMove , false ) ;
857
+ document . addEventListener ( "mouseup" , self . mouseUp , false ) ;
858
+ document . addEventListener ( 'mousewheel' , self . mouseWheel , false ) ;
856
859
}
857
860
} ,
858
861
862
+ __removeEventHandlers : function ( ) {
863
+ var container = this . __container ;
864
+
865
+ container . removeEventListener ( 'touchstart' , self . touchStart ) ;
866
+ document . removeEventListener ( 'touchmove' , self . touchMove ) ;
867
+ document . removeEventListener ( 'touchend' , self . touchEnd ) ;
868
+ document . removeEventListener ( 'touchcancel' , self . touchCancel ) ;
869
+
870
+ container . removeEventListener ( "pointerdown" , self . touchStart ) ;
871
+ document . removeEventListener ( "pointermove" , self . touchMove ) ;
872
+ document . removeEventListener ( "pointerup" , self . touchEnd ) ;
873
+ document . removeEventListener ( "pointercancel" , self . touchEnd ) ;
874
+
875
+ container . removeEventListener ( "MSPointerDown" , self . touchStart ) ;
876
+ document . removeEventListener ( "MSPointerMove" , self . touchMove ) ;
877
+ document . removeEventListener ( "MSPointerUp" , self . touchEnd ) ;
878
+ document . removeEventListener ( "MSPointerCancel" , self . touchEnd ) ;
879
+
880
+ container . removeEventListener ( "mousedown" , self . mouseDown ) ;
881
+ document . removeEventListener ( "mousemove" , self . mouseMove ) ;
882
+ document . removeEventListener ( "mouseup" , self . mouseUp ) ;
883
+ document . removeEventListener ( 'mousewheel' , self . mouseWheel ) ;
884
+ } ,
885
+
859
886
/** Create a scroll bar div with the given direction **/
860
887
__createScrollbar : function ( direction ) {
861
888
var bar = document . createElement ( 'div' ) ,
@@ -1503,7 +1530,6 @@ ionic.views.Scroll = ionic.views.View.inherit({
1503
1530
1504
1531
} ,
1505
1532
1506
-
1507
1533
/**
1508
1534
* Touch start handler for scrolling support
1509
1535
*/
0 commit comments