@@ -63,7 +63,8 @@ export class PickerColumnCmp {
63
63
private elementRef : ElementRef ,
64
64
private _sanitizer : DomSanitizer ,
65
65
private _zone : NgZone ,
66
- private _haptic : Haptic ) {
66
+ private _haptic : Haptic
67
+ ) {
67
68
this . rotateFactor = config . getNumber ( 'pickerRotateFactor' , 0 ) ;
68
69
this . scaleFactor = config . getNumber ( 'pickerScaleFactor' , 1 ) ;
69
70
this . decelerateFunc = this . decelerate . bind ( this ) ;
@@ -104,47 +105,46 @@ export class PickerColumnCmp {
104
105
// some "click" events to capture
105
106
ev . preventDefault ( ) ;
106
107
107
- this . debouncer . debounce ( ( ) => {
108
- // cancel any previous raf's that haven't fired yet
109
- if ( this . rafId ) {
110
- cancelRaf ( this . rafId ) ;
111
- this . rafId = null ;
112
- }
108
+ // cancel any previous raf's that haven't fired yet
109
+ if ( this . rafId ) {
110
+ cancelRaf ( this . rafId ) ;
111
+ this . rafId = null ;
112
+ }
113
113
114
- // remember where the pointer started from`
115
- this . startY = pointerCoord ( ev ) . y ;
116
-
117
- // reset everything
118
- this . velocity = 0 ;
119
- this . pos . length = 0 ;
120
- this . pos . push ( this . startY , Date . now ( ) ) ;
121
-
122
- let options = this . col . options ;
123
- let minY = ( options . length - 1 ) ;
124
- let maxY = 0 ;
125
- for ( var i = 0 ; i < options . length ; i ++ ) {
126
- if ( ! options [ i ] . disabled ) {
127
- minY = Math . min ( minY , i ) ;
128
- maxY = Math . max ( maxY , i ) ;
129
- }
114
+ // remember where the pointer started from`
115
+ this . startY = pointerCoord ( ev ) . y ;
116
+
117
+ // reset everything
118
+ this . velocity = 0 ;
119
+ this . pos . length = 0 ;
120
+ this . pos . push ( this . startY , Date . now ( ) ) ;
121
+
122
+ let options = this . col . options ;
123
+ let minY = ( options . length - 1 ) ;
124
+ let maxY = 0 ;
125
+ for ( var i = 0 ; i < options . length ; i ++ ) {
126
+ if ( ! options [ i ] . disabled ) {
127
+ minY = Math . min ( minY , i ) ;
128
+ maxY = Math . max ( maxY , i ) ;
130
129
}
130
+ }
131
131
132
- this . minY = ( minY * this . optHeight * - 1 ) ;
133
- this . maxY = ( maxY * this . optHeight * - 1 ) ;
134
- } ) ;
132
+ this . minY = ( minY * this . optHeight * - 1 ) ;
133
+ this . maxY = ( maxY * this . optHeight * - 1 ) ;
135
134
return true ;
136
135
}
137
136
138
137
pointerMove ( ev : UIEvent ) {
139
138
ev . preventDefault ( ) ;
140
139
ev . stopPropagation ( ) ;
141
140
141
+ let currentY = pointerCoord ( ev ) . y ;
142
+ this . pos . push ( currentY , Date . now ( ) ) ;
143
+
142
144
this . debouncer . debounce ( ( ) => {
143
145
if ( this . startY === null ) {
144
146
return ;
145
147
}
146
- let currentY = pointerCoord ( ev ) . y ;
147
- this . pos . push ( currentY , Date . now ( ) ) ;
148
148
149
149
// update the scroll position relative to pointer start position
150
150
let y = this . y + ( currentY - this . startY ) ;
@@ -214,7 +214,8 @@ export class PickerColumnCmp {
214
214
var movedTop = ( this . pos [ startPos - 1 ] - this . pos [ endPos - 1 ] ) ;
215
215
216
216
// based on XXms compute the movement to apply for each render step
217
- this . velocity = ( ( movedTop / timeOffset ) * FRAME_MS ) ;
217
+ var velocity = ( ( movedTop / timeOffset ) * FRAME_MS ) ;
218
+ this . velocity = clamp ( - MAX_PICKER_SPEED , velocity , MAX_PICKER_SPEED ) ;
218
219
}
219
220
220
221
if ( Math . abs ( endY - this . startY ) > 3 ) {
@@ -641,3 +642,4 @@ let pickerIds = -1;
641
642
const PICKER_OPT_SELECTED = 'picker-opt-selected' ;
642
643
const DECELERATION_FRICTION = 0.97 ;
643
644
const FRAME_MS = ( 1000 / 60 ) ;
645
+ const MAX_PICKER_SPEED = 50 ;
0 commit comments