Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate scroll :target #69

Merged
merged 4 commits into from
Aug 20, 2023
Merged

Emulate scroll :target #69

merged 4 commits into from
Aug 20, 2023

Conversation

daun
Copy link
Member

@daun daun commented Aug 20, 2023

Description

  • Emulate native :target selector that stops working when updating URLs via History API
  • Introduce a setting markScrollTarget to mark targets with a data-swup-scroll-target attribute
  • Waiting on PR #772 on the core to work properly

Checks

  • The PR is submitted to the master branch
  • The code was linted before pushing (npm run lint)
  • The documentation was updated as required

Additional information

Closes #53

@daun daun requested a review from a team August 20, 2023 20:26
@hirasso
Copy link
Member

hirasso commented Aug 20, 2023

Did you test the exact native behavior of :target? If I recall correctly, the selector is not being applied if clicking on an anchor link that scrolls on the same page. It's only applied if visiting a page with a hash anchor directly, doesn't it?

I'm only on mobile so I can't properly test it right now 😩😉

@daun
Copy link
Member Author

daun commented Aug 20, 2023

@hirasso As far as I know, :target gets updated whenever the URL changes, which also happens when jumping between anchors on the same page.

@daun daun merged commit c438bde into master Aug 20, 2023
@daun daun deleted the feature/emulate-scroll-target branch August 20, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emulate :target to allow styling anchor element
2 participants