Good morning,
I’m facing an issue, when I click a second time on the title header.
The issue, is that the scroll goes to the top position and stays there.
The expected behaviour is to have it stay at the same position.
In order to scroll to the according section I’m using the tactic that @flo uses.
The process assigns an id called container
to the Gallery Images element, allowing the script to use it as a parentNode
to navigate and scroll to a specific position also tag with an id within the container.
While doing it, my page does goes to the according position but if I click again on the same button it starts to behave strangely.
Basically it goes to the top again and stops.
–
Here is the structure I use, as you can see the title menu doesn’t have ID itself :
But it does have a workflow :
Here is the code I put into the workflow in order to scroll to the `location` position :
let container = wwLib.getFrontDocument().getElementById("container").parentNode;
let access = wwLib.getFrontDocument().getElementById("location");
if (container && access) {
let offsetPosition = access.getBoundingClientRect().top;
container.scrollTo({ top: offsetPosition, behavior: "smooth" });
}
Here is the setup of my container :
Here is the setup of the Location section with it’s ID sets to location
:
Here is a demo of the behaviour :
https://www.loom.com/share/a1838146208e4a73b7ac7e44b1f5a298?sid=33f28e16-fb81-4b3b-810e-9eff647af092
I think there is a mistake in the JS script in a way that it tries to access the parentNode on the second clicks which is used as a reference and stop, there third click goes to the correct section again.
I’d like your advice on this please.
Thank you very much in advance for your help,
Best,