page-scroll-to-id icon indicating copy to clipboard operation
page-scroll-to-id copied to clipboard

Offset is not applied

Open ghost opened this issue 7 years ago • 7 comments

When a tab is clicked, the offset is taken into account and and the page will scroll to the target element plus the offset pixels.

However, when scrolling, the offset is not taken into account and the active link is activated when the target is at the very top of the screen, ignoring the offset.

I hope you can find the time to respond.

ghost avatar Jun 07 '17 04:06 ghost

I can't really help unless I see your page. Can you post a link and the steps to replicate the issue?

malihu avatar Jun 07 '17 11:06 malihu

https://codepen.io/anon/pen/mwJNxQ?editors=1000 with an offset of 100, when you click a tab the page scrolls to the target plus the offset. However the corresponding tab is activated, but not when the target reaches the header. Meaning the offset is ignored when manually scrolling.

ghost avatar Jun 07 '17 13:06 ghost

Yes, this is the expected behavior. Highlighting works independently from the target scroll-to position and offset.

Plugin's highlighting feature is completely user-centric. It works as an indicator to the user as to which section he/she is currently viewing. All that matters for the plugin script, is whether or not a section is within the visual field of the user (from top or bottom). It is not dependant on where the link scrolls (at which the offset applies).

Hope this helps

malihu avatar Jun 07 '17 14:06 malihu

Would you please add an option that highlights the tab based on the target plus the offset when the user scrolls manually?

ghost avatar Jun 07 '17 16:06 ghost

I can't really say if or when such option will be implemented as it'll probably interfere with other highlighting options and its core scope (such feature will require a lot of testing in various layouts).

malihu avatar Jun 07 '17 16:06 malihu

I understand and hope you can implement it some day. It would make the plugin perfect. Thank you for your work.

ghost avatar Jun 07 '17 17:06 ghost

You're welcome :)

malihu avatar Jun 07 '17 17:06 malihu