Forum Discussion
Scroll Into View JavaScript Trigger Not Working
Uploading the .story file. My suspicion is the parameter "nearest" is the culprit.
- SamHill10 months agoSuper Hero
Hi Ray,
I tested this by running the script directly in the browser console. I adjusted your script a little, as it was not necassary to querySelectorAll as you are only grabbing a single element, so it is better to use querySelector and return the single element you want to use.
// querySelector as we're only looking for a single element
var zoneone = document.querySelector('[data-acc-text="modone"]');
// passing the arg false (shorthand)
zoneone.scrollIntoView(false);Now, the results, they are good in the browser console and work perfectly, scrolling the element into view at the bottom of the panel as expected. However, adding the same script to SL and triggering via the button, scrolls the content, but doesn't bring the element into view. It's short by several pixels and I'm not sure why this would be, and why there would be a difference between running via SL and running in the browser console.
Anyway, thought I'd just share that script with you, as it inches you a bit closer to a solution.
I'll see if I can find why this occurs.
Cheers,
Sam