leecade / leecade/react-native-swiper

this.internal.isScrolling is not setting to false when swipe right at last index

Open
#983 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Which OS ?

Android 9

Version

Which versions are you using:
1.5.14

  • react-native-swiper v? 1.5.14
  • react-native v0.?.? 0 .55.3
Expected behaviour

When we swipe right on the last screen of swiper, it triggers onScrollBegin , but does not trigger onScrollEnd on Android
Reason: onScrollEnd is triggered when page is changed inside ViewPager
Due to this this.internal.isScrolling is set to true in onSrollBegin , but never set to false . So, we cannot use scrollBy function on swiper in this case.

Actual behaviour

this.internal.isScrolling should be set to false in case of idle or settling of ViewPager

Code in which there is problem:

Updated code in library:

onScrollBegin = e => {
console.log("Yogesh onSCrollBegin ===> setting isScrolling to true");
// update scroll state
this.internals.isScrolling = true
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e, this.fullState(), this)
}

/**

  • Scroll end handle
  • @param {object} e native event
    */
    onScrollEnd = e => {
    console.log("Yogesh onScrollEnd ===> setting isScrolling to false");
    // update scroll state
    this.internals.isScrolling = false
// making our events coming from android compatible to updateIndex logic
if (!e.nativeEvent.contentOffset) {
  if (this.state.dir === 'x') {
    e.nativeEvent.contentOffset = {x: e.nativeEvent.position * this.state.width}
  } else {
    e.nativeEvent.contentOffset = {y: e.nativeEvent.position * this.state.height}
  }
}

onPageScrollStateChanged = state => {
console.log("Yogesh " + state);
switch (state) {
case 'dragging':
return this.onScrollBegin();

  case 'idle':
  case 'settling':
    if (this.props.onTouchEnd) this.props.onTouchEnd();
}

}

Normal case (when user swipes)
Logs:

05-22 17:36:12.010 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh dragging
05-22 17:36:12.011 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh onSCrollBegin ===> setting isScrolling to true
05-22 17:36:12.066 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh settling
05-22 17:36:12.069 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh onScrollEnd ===> setting isScrolling to false
05-22 17:36:12.567 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh idle

Issue case (when user swipes right at last index)

05-22 17:37:16.314 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh dragging
Yogesh onSCrollBegin ===> setting isScrolling to true
05-22 17:37:16.442 3820-18105/com.amazon.kindle.guru I/ReactNativeJS: Yogesh idle

So, here scroll end is missing due to which this.internals.isScrolling state is not proper

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Android ViewPager event path, especially onPageScrollStateChanged, and trace how dragging, settling, and idle reach onScrollBegin and onScrollEnd. Reproduce the last-index swipe on Android 9 with react-native-swiper 1.5.14, then verify that isScrolling is reset and scrollBy works afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.