1
1
import { Activator } from './activator' ;
2
2
import { App } from '../app/app' ;
3
- import { CSS , nativeRaf , rafFrames } from '../../util/dom' ;
3
+ import { Coordinates , CSS , hasPointerMoved , nativeRaf , pointerCoord , rafFrames } from '../../util/dom' ;
4
4
import { Config } from '../../config/config' ;
5
5
6
6
@@ -13,7 +13,7 @@ export class RippleActivator extends Activator {
13
13
super ( app , config ) ;
14
14
}
15
15
16
- downAction ( ev : UIEvent , activatableEle : HTMLElement , pointerX : number , pointerY : number ) {
16
+ downAction ( ev : UIEvent , activatableEle : HTMLElement , startCoord : Coordinates ) {
17
17
let self = this ;
18
18
if ( self . disableActivated ( ev ) ) {
19
19
return ;
@@ -56,47 +56,50 @@ export class RippleActivator extends Activator {
56
56
} ) ;
57
57
}
58
58
59
- upAction ( ev : UIEvent , activatableEle : HTMLElement , pointerX : number , pointerY : number ) {
59
+ upAction ( ev : UIEvent , activatableEle : HTMLElement , startCoord : Coordinates ) {
60
60
let self = this ;
61
61
62
- var i = activatableEle . childElementCount ;
63
- while ( i -- ) {
64
- var rippleEle : any = activatableEle . children [ i ] ;
65
- if ( rippleEle . tagName === 'ION-BUTTON-EFFECT' ) {
66
- var clientPointerX = ( pointerX - rippleEle . $left ) ;
67
- var clientPointerY = ( pointerY - rippleEle . $top ) ;
62
+ if ( ! hasPointerMoved ( 6 , startCoord , pointerCoord ( ev ) ) ) {
63
+ let i = activatableEle . childElementCount ;
68
64
69
- var x = Math . max ( Math . abs ( rippleEle . $width - clientPointerX ) , clientPointerX ) * 2 ;
70
- var y = Math . max ( Math . abs ( rippleEle . $height - clientPointerY ) , clientPointerY ) * 2 ;
71
- var diameter = Math . min ( Math . max ( Math . sqrt ( Math . pow ( x , 2 ) + Math . pow ( y , 2 ) ) , 64 ) , 240 ) ;
65
+ while ( i -- ) {
66
+ var rippleEle : any = activatableEle . children [ i ] ;
67
+ if ( rippleEle . tagName === 'ION-BUTTON-EFFECT' ) {
68
+ var clientPointerX = ( startCoord . x - rippleEle . $left ) ;
69
+ var clientPointerY = ( startCoord . y - rippleEle . $top ) ;
72
70
73
- if ( activatableEle . hasAttribute ( 'ion-item' ) ) {
74
- diameter = Math . min ( diameter , 140 ) ;
75
- }
71
+ var x = Math . max ( Math . abs ( rippleEle . $width - clientPointerX ) , clientPointerX ) * 2 ;
72
+ var y = Math . max ( Math . abs ( rippleEle . $height - clientPointerY ) , clientPointerY ) * 2 ;
73
+ var diameter = Math . min ( Math . max ( Math . sqrt ( Math . pow ( x , 2 ) + Math . pow ( y , 2 ) ) , 64 ) , 240 ) ;
74
+
75
+ if ( activatableEle . hasAttribute ( 'ion-item' ) ) {
76
+ diameter = Math . min ( diameter , 140 ) ;
77
+ }
78
+
79
+ var radius = Math . sqrt ( rippleEle . $width + rippleEle . $height ) ;
76
80
77
- var radius = Math . sqrt ( rippleEle . $width + rippleEle . $height ) ;
78
-
79
- var scaleTransitionDuration = Math . max ( 1600 * Math . sqrt ( radius / TOUCH_DOWN_ACCEL ) + 0.5 , 260 ) ;
80
- var opacityTransitionDuration = scaleTransitionDuration * 0.7 ;
81
- var opacityTransitionDelay = scaleTransitionDuration - opacityTransitionDuration ;
82
-
83
- // DOM WRITE
84
- rippleEle . style . width = rippleEle . style . height = diameter + 'px' ;
85
- rippleEle . style . marginTop = rippleEle . style . marginLeft = - ( diameter / 2 ) + 'px' ;
86
- rippleEle . style . left = clientPointerX + 'px' ;
87
- rippleEle . style . top = clientPointerY + 'px' ;
88
- rippleEle . style . opacity = '0' ;
89
- rippleEle . style [ CSS . transform ] = 'scale(1) translateZ(0px)' ;
90
- rippleEle . style [ CSS . transition ] = 'transform ' +
91
- scaleTransitionDuration +
92
- 'ms,opacity ' +
93
- opacityTransitionDuration +
94
- 'ms ' +
95
- opacityTransitionDelay + 'ms' ;
81
+ var scaleTransitionDuration = Math . max ( 1600 * Math . sqrt ( radius / TOUCH_DOWN_ACCEL ) + 0.5 , 260 ) ;
82
+ var opacityTransitionDuration = scaleTransitionDuration * 0.7 ;
83
+ var opacityTransitionDelay = scaleTransitionDuration - opacityTransitionDuration ;
84
+
85
+ // DOM WRITE
86
+ rippleEle . style . width = rippleEle . style . height = diameter + 'px' ;
87
+ rippleEle . style . marginTop = rippleEle . style . marginLeft = - ( diameter / 2 ) + 'px' ;
88
+ rippleEle . style . left = clientPointerX + 'px' ;
89
+ rippleEle . style . top = clientPointerY + 'px' ;
90
+ rippleEle . style . opacity = '0' ;
91
+ rippleEle . style [ CSS . transform ] = 'scale(1) translateZ(0px)' ;
92
+ rippleEle . style [ CSS . transition ] = 'transform ' +
93
+ scaleTransitionDuration +
94
+ 'ms,opacity ' +
95
+ opacityTransitionDuration +
96
+ 'ms ' +
97
+ opacityTransitionDelay + 'ms' ;
98
+ }
96
99
}
97
100
}
98
101
99
- super . upAction ( ev , activatableEle , pointerX , pointerY ) ;
102
+ super . upAction ( ev , activatableEle , startCoord ) ;
100
103
}
101
104
102
105
deactivate ( ) {
0 commit comments