@@ -119,8 +119,6 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
119119 sendEvent ("onCustomScrollBeginDrag" , null );
120120 }
121121 dragging = true ;
122- NativeGestureUtil .notifyNativeGestureStarted (this , ev );
123- ReactScrollViewHelper .emitScrollBeginDragEvent (this );
124122 getParent ().requestDisallowInterceptTouchEvent (true );
125123 }
126124 break ;
@@ -145,8 +143,8 @@ private boolean shouldDrag(MotionEvent ev) {
145143 if (!scrollEnabled ) return false ;
146144 if (beginPoint .x == 0 && beginPoint .y == 0 ) return false ;
147145 if (dragging ) return true ;
148- if (canHorizontalScroll ()) {
149- return Math . abs ( ev . getX () - beginPoint . x ) > PixelUtil . toPixelFromDIP ( 10 ) ;
146+ if (canHorizontalScroll () && Math . abs ( ev . getX () - beginPoint . x ) > PixelUtil . toPixelFromDIP ( 10 ) ) {
147+ return true ;
150148 }
151149 return Math .abs (ev .getY () - beginPoint .y ) > PixelUtil .toPixelFromDIP (5 );
152150 }
@@ -216,15 +214,12 @@ private void onUp(MotionEvent evt) {
216214 }
217215
218216 private void beginInnerHorizontalAnimation (final float initialVelocity ) {
219- if (Math .abs (initialVelocity ) < 0.1f ) {
220- return ;
221- }
222217 if (!momentumScrolling ) {
223218 momentumScrolling = true ;
224219 sendEvent ("onCustomMomentumScrollBegin" , null );
225220 }
226221 final long beginTimeInterval = System .currentTimeMillis ();
227- float dampingCoefficient = pagingEnabled ? 0.99f : 0.997f ;
222+ final float dampingCoefficient = pagingEnabled ? 0.99f : 0.997f ;
228223 float end ;
229224 float displacement = 0 ;
230225 float v = initialVelocity ;
@@ -236,7 +231,7 @@ private void beginInnerHorizontalAnimation(final float initialVelocity) {
236231 }
237232 if (pagingEnabled ) {
238233 duration = 500 ;
239- end = Math .round ((contentOffset .x - displacement ) / getPageSize (). width ) * getPageSize (). width ;
234+ end = Math .round ((contentOffset .x - displacement ) / getPageWidth () ) * getPageWidth () ;
240235 } else {
241236 end = contentOffset .x - displacement ;
242237 }
@@ -248,16 +243,15 @@ public void onDecelerateUpdate(DecelerateAnimation animation, float value) {
248243 long interval = System .currentTimeMillis () - beginTimeInterval ;
249244 float v = initialVelocity ;
250245 while (interval -- > 0 ) {
251- v *= 0.997f ;
246+ v *= dampingCoefficient ;
252247 }
253248 animation .cancel ();
254249 beginOuterHorizontalAnimation (v );
255250 }
256251 }
257252
258253 @ Override
259- public void onDecelerateEnd (DecelerateAnimation animation ) {
260- }
254+ public void onDecelerateEnd (DecelerateAnimation animation ) {}
261255 });
262256 horizontalAnimation .start ();
263257 }
@@ -293,17 +287,13 @@ private void beginHorizontalReboundAnimation() {
293287 }
294288
295289 private void beginInnerAnimation (final float initialVelocity ) {
296- if (Math .abs (initialVelocity ) < 0.1f ) {
297- onVerticalAnimationEnd ();
298- return ;
299- }
300290 if (!momentumScrolling ) {
301291 momentumScrolling = true ;
302292 sendEvent ("onCustomMomentumScrollBegin" , null );
303293 }
304294 final long beginTimeInterval = System .currentTimeMillis ();
305295 float end ;
306- float dampingCoefficient = pagingEnabled ? 0.99f : 0.997f ;
296+ final float dampingCoefficient = pagingEnabled ? 0.99f : 0.997f ;
307297 float displacement = 0 ;
308298 float v = initialVelocity ;
309299 int duration = 0 ;
@@ -314,7 +304,7 @@ private void beginInnerAnimation(final float initialVelocity) {
314304 }
315305 if (pagingEnabled ) {
316306 duration = 500 ;
317- end = Math .round ((contentOffset .y - displacement ) / getPageSize (). height ) * getPageSize (). height ;
307+ end = Math .round ((contentOffset .y - displacement ) / getPageHeight () ) * getPageHeight () ;
318308 } else {
319309 end = contentOffset .y - displacement ;
320310 }
@@ -326,7 +316,7 @@ public void onDecelerateUpdate(DecelerateAnimation animation, float value) {
326316 long interval = System .currentTimeMillis () - beginTimeInterval ;
327317 float v = initialVelocity ;
328318 while (interval -- > 0 ) {
329- v *= 0.997f ;
319+ v *= dampingCoefficient ;
330320 }
331321 animation .cancel ();
332322 beginOuterAnimation (v );
@@ -393,7 +383,7 @@ private boolean cancelAllAnimations() {
393383 if (horizontalAnimation .animating ) {
394384 cancelHorizontal = horizontalAnimation .cancel ();
395385 }
396- return cancelVertical || cancelVertical ;
386+ return cancelVertical || cancelHorizontal ;
397387 }
398388
399389
@@ -601,8 +591,12 @@ public void setPageSize(float width, float height) {
601591 this .pageSize .height = height ;
602592 }
603593
604- public Size getPageSize () {
605- return pageSize .width == 0 && pageSize .height == 0 ? contentSize : pageSize ;
594+ private float getPageWidth () {
595+ return pageSize .width <= 0 ? size .width : pageSize .width ;
596+ }
597+
598+ private float getPageHeight () {
599+ return pageSize .height <= 0 ? size .height : pageSize .height ;
606600 }
607601
608602 private boolean overshootHead () {
0 commit comments