@@ -96,12 +96,6 @@ function QpToastService($timeout, $rootScope, $materialCompiler, $rootElement, $
96
96
toastParent = $rootElement ;
97
97
}
98
98
99
- // Which swipe events to listen for, depending on the toast's position
100
- var positionSwipeEvents = {
101
- top : 'swipeleft swiperight swipeup' ,
102
- bottom : 'swipeleft swiperight swipedown'
103
- } ;
104
-
105
99
return showToast ;
106
100
107
101
/**
@@ -139,13 +133,15 @@ function QpToastService($timeout, $rootScope, $materialCompiler, $rootElement, $
139
133
}
140
134
} ) ;
141
135
142
- var isTop = options . position . indexOf ( 'top' ) > - 1 ;
143
- var swipeEvents = positionSwipeEvents [ isTop ? 'top' : 'bottom' ] ;
144
- var mc = new Hammer ( element [ 0 ] ) ;
145
- mc . on ( swipeEvents , onSwipe ) ;
136
+ var hammer = new Hammer ( element [ 0 ] , {
137
+ recognizers : [
138
+ [ Hammer . Swipe , { direction : Hammer . DIRECTION_HORIZONTAL } ]
139
+ ]
140
+ } ) ;
141
+ hammer . on ( 'swipeleft swiperight' , onSwipe ) ;
146
142
147
143
function onSwipe ( ev ) {
148
- //Add swipeleft/swiperight/swipeup/swipedown class to element
144
+ //Add swipeleft/swiperight class to element so it can animate correctly
149
145
element . addClass ( ev . type ) ;
150
146
$timeout ( destroy ) ;
151
147
}
@@ -156,7 +152,7 @@ function QpToastService($timeout, $rootScope, $materialCompiler, $rootElement, $
156
152
if ( destroy . called ) return ;
157
153
destroy . called = true ;
158
154
159
- mc . destroy ( ) ;
155
+ hammer . destroy ( ) ;
160
156
toastParent . removeClass ( toastParentClass ) ;
161
157
$timeout . cancel ( delayTimeout ) ;
162
158
$animate . leave ( element , function ( ) {
0 commit comments