-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
offset always returns zero within a modal #986
Comments
Just now I found this which might be relevant here as well. I will dig into it. |
Yeah, triggering offset with the @open event solved it. |
Uh, do you maybe have a suggestion which event to use exactly? At the open event the css apparently is not loaded since when the list of cards gets larger I see the offset losing accuracy, so it is called 'too early'. When I use setTimeout(myFunction, 200) I get good results, I would prefer using an accurate event though. I tried:
Both do not work. It seems maybe because the modal is already mounted, so it is not triggered when it opens... Any help maybe? |
I could be wrong, bat maybe it's all because of the asynchronous animation. Try to play with the last argument of |
I already did, but keeps same problem. |
I had solved the similar problem (scroll specific card to ScrollArea's center ) as follows. scrollToRecord ({pos}) {
const target = scroll.getScrollTarget(this.$refs['list'].$el)
if (target) {
const activeCard = this.$refs['list'].children[pos]
let offset = activeCard ? activeCard.offsetTop : 0
offset -= Math.floor(this.$refs['scroll'].$el.clientHeight / 2)
offset += Math.floor(activeCard.clientHeight / 2)
scroll.setScrollPosition(target, offset)
}
} |
@igorgo Thanks! My problem is not determining the accurate scrolldistance for the card. Using |
Hi,
|
@rstoenescu Just to be clear: my code 'works': the scroll does happen. My problem is the correct triggermoment. I have to set a delay otherwise the dom is not ready or something. I did alter my code after your comment:
But my issue remains the same. When I set setTimeout(myFunction, 0) the myOffset is not accurate. |
|
@rstoenescu Pheew! That's it! Thanks a bunch!!! |
I have a modal with cards in it, which works fine. I would like the modal to have scrolled to a specific (not at the top) card when opening the modal, but I run into problems.
I am trying to use getScrollTarget and setScrollPosition following the docs. E.g. I can do:
setScrollPosition(getScrollTarget(element[0]), 500, 1200)
Which works nicely and shows an animated scroll of 500 px. To scroll to the correct card I need to set the correct distance of px so I would like to use:
offset(element[0])
But this always returns 0. Also
getScrollbarWidth
gives 0.When I use these methods in a non modal window with cards I do get sensible values. So, is there a reason why
offset
does not work within the modal?My component:
The text was updated successfully, but these errors were encountered: