meliorence / meliorence/react-native-snap-carousel

[Web] Snap to item after scrolling

Open
#822 1 comment 6 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

Is this a bug report, a feature request, or a question?

Question

[Web] When the user has finished scrolling (e.g. using a touchpad double-finger swipe), snapToItem is not called. When programmatically calling snapToNext, snapToPrev or snapToItem, the snap instead causes it to scroll to an item near where the user was before they started scrolling.

Is there any way to fix this?

I understand web isn't officially listed as supported by the library, but I'm hoping someone can shed some light on a possible solution.

Have you followed the required steps before opening a bug report?
Have you made sure that it wasn't a React Native bug?

Yes

Is the bug specific to Web, iOS or Android? Or can it be reproduced on both platforms?

Web - issue not present on Android (11) or iOS (14)

Is the bug reproductible in a production environment (not a debug one)?

Yes

Environment

React: 16.11.0
React native: Expo SDK 38
React native snap carousel: 3.9.1

Expected Behavior

When the user has finished scrolling, the carousel should snap to the item nearest to the snap point, in the same way it does on iOS and Android.

Actual Behavior

The snap event never triggers on web after scrolling.

  • When snapToNext is called, it snaps to the next item that the user was at BEFORE they started scrolling
  • When snapToPrev is called, it snaps to the previous item that the user was at BEFORE they started scrolling
Further info

I have attempted to use onViewableItemsChanged and viewabilityConfig in order to implement the functionality, but unfortunately, this causes other side effects such as snapping back to the first item after reaching the end when loop={true}.

I did attempt to use V4 of the library, but this introduces other issues.

It also doesn't appear to be possible to simply click + drag in order to scroll the carousel on web, meaning that users without a trackpad access are unable to scroll it. Implementing support for this would be a huge benefit.

Contributor guide

Open the contributing guide

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

The issue names no files or tests. First reproduce the reported touchpad-scroll behavior on the web with React Native Snap Carousel 3.9.1, then trace how web scrolling and snapping are handled. Done means scrolling snaps to the nearest item and programmatic snapping uses the current position without regressing Android or iOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.