fix(card-carousel): use CSS scroll-behavior instead of JS behavior:'s…#42
Open
krishpranav wants to merge 1 commit into
Open
fix(card-carousel): use CSS scroll-behavior instead of JS behavior:'s…#42krishpranav wants to merge 1 commit into
krishpranav wants to merge 1 commit into
Conversation
…mooth'
The click handler was calling scrollBy() with an explicit ScrollToOptions
{ behavior: 'smooth' }, which overrides the element's CSS scroll-behavior
property. On WebKit (Safari / iOS), this combination with scroll-snap-type:
mandatory prevents the snap point from being committed — the carousel either
fails to move or lands between slides.
The fix drops ScrollBehavior::Smooth and ScrollToOptions entirely, switching
to scroll_by_with_x_and_y(delta, 0.0). This matches the original JS
implementation which relied on the track's CSS scroll-smooth class for
animation and let the browser's native snap logic run uninterrupted.
Removed the now-unused ScrollBehavior and ScrollToOptions web-sys features
from the workspace Cargo.toml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
After PR #39, the carousel nav buttons stopped working on WebKit based browsers.
Fix
The JS
scrollBy()call with explicitbehavior: 'smooth'was conflicting withscroll-snap-type: mandatoryon WebKit.Switched to
scroll_by_with_x_and_y()(default auto behavior) so it respects the CSSscroll-behavior: smooth. Also cleaned up unusedweb-sysfeatures.Tested with
cargo build+cargo clippy. Fixes the regression from #39.