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

Anchor Tags not working with horizontal scrolling #509

Open
1 task done
nzmitch opened this issue Nov 28, 2022 · 4 comments
Open
1 task done

Anchor Tags not working with horizontal scrolling #509

nzmitch opened this issue Nov 28, 2022 · 4 comments

Comments

@nzmitch
Copy link

nzmitch commented Nov 28, 2022

Checks

  • Not a duplicate.

Version

^8.8.1

Description

I think I've found a bug when it comes to horizontal scrolling and anchor tags.

https://jsbin.com/romofifado/1/edit?html,css,js,output

I've reproduced the bug above.

#target doesn't jump to 001.

Steps to Reproduce

Horizontal scrolling on my website uses

.wrapper {
  display: flex;
  flex-direction: row;
  max-width: 100vw;
  transform: rotate(90deg) translateY(-100vh);
  transform-origin: top left;
  object-fit: cover;
}

.outer-wrapper {
  width: 100vh;
  height: 100vw;
  transform: rotate(-90deg) translateX(-100vh);
  transform-origin: top left;
  overflow-y: hidden;
  overflow-x: hidden;
  position: absolute;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

Online Demo

https://jsbin.com/romofifado/1/edit?html,css,js,output

@frussane
Copy link

@nzmitch did you manage to make it work?

@idiotWu
Copy link
Owner

idiotWu commented Feb 15, 2023

I guess you have to swap x and y when rotating the scrolling area by 90 degrees because the coordinate system has been changed. More generally, we could have a plugin to negate the rotation by transforming the scrolling delta (applying trigonometric functions.)

@sadeghbarati I believe this is not a bug, but I don’t have time to validate my idea at this moment. Please have a look when you have time.

More details:
When rotating the scrolling area by 90 degrees clockwise, top and right we get from getBoundingClientRect() become left and top in the local coordinate system. So we need to scroll to x = container.top - target.top; y = container.right - target.right.

@idiotWu
Copy link
Owner

idiotWu commented Feb 15, 2023

However, my suggestion is to use the horizontal scroll plugin (#359 (comment)) when you want to redirect scrollY to scrollX. Applying CSS transformations like this will create a local coordinate system and cause some unexpected consequences.

@sadeghbarati
Copy link
Collaborator

sadeghbarati commented Feb 15, 2023

@nzmitch

I guess you want to use writing-mode with smooth-scrollbar?

https://codepen.io/sadeghbarati/pen/ExexMMZ

CodePen demo does not support RTL horizontal

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

No branches or pull requests

4 participants