Scroll Into View troubles
Anyone know why
Element.scrollIntoViewIfNeeded()
is working, but Element.scrollIntoView()
isn't?
The IfNeeded version is apparently "Non-Standard" https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
Not sure what I should do here...
Could someone test which works best on your Foundry instance?36 Replies
Take a look if there's a jQuery utility for that
But JQuery is bad...
While yes
This is exactly it's use case
Under the skin, jQuery has a lot of cruft that more or less ensures cross browser support
That's one reason why it's been left, has a lot of old bad code. There's points though where you want those fallbacks
You Might Not Need jQuery
Examples of how to do common event, element, ajax and utility operations with plain javascript.
Another thing to take a look at
Do you see an issue with just using
scrollIntoViewIfNeeded()
? It seems to work perfectly
and its vanilla I think I'm going to continue using what I have now since it seems to work fine, but thanks!@arcanistzed gave LeaguePoints™ to @mouse0270 (#49 • 32)
@arcanistzed
No Firefox support looks like
No one use Firefox 😏
Fine, I'll use JQuery
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
The thing is, developing for Foundry is my first experience with development, so I'm learning all of the habits I will have for the rest of my career. I don't want to be dependent on JQuery
So, if there's any other way, I would prefer it
Felt dirty coming back to jQuery after so long
The thing is, scrolling to a place it's kinda difficult to do in a performant, cross browser way. Every platform/framework's got some quirk to make it happen.
At work mine is telling product "we don't do that"
We did it once, it was buggy as hell and you hated it, we're not doing it again
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
I'll try that, thanks
I can always add my own animations 🙂
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
You get a point for giving an answer either way 🙂
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Try this I conjunction:
https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior
scroll-behavior - CSS: Cascading Style Sheets | MDN
The scroll-behavior CSS property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs.
I tried using anchors and running
location.href = "#elementId"
, but that shows: "Are you sure you want to leave this page?"Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Yes, before
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
I haven't tried your thing yet (not at computer)
It looks a bit weird because the current phase is always on top. I would expect that it only changes once the element isn't visible.
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
You can always use jQuerys $('#CONTAINER').scrollTo('#TARGET');
which would on pretty much any browser.
Doesn't work :/Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
I don't see the advantage in that case
yeah
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
This is exactly what I had been trying except for the height, thanks!
@arcanistzed gave LeaguePoints™ to @mouse0270 (#47 • 34)
This only scrolls down 🤔
Figured it out though!
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View