Skip to content
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

Scrolling within a modal #304

Open
AbrahamBrookes opened this issue Jun 22, 2020 · 7 comments
Open

Scrolling within a modal #304

AbrahamBrookes opened this issue Jun 22, 2020 · 7 comments

Comments

@AbrahamBrookes
Copy link

Hi this plugin works great when the component is a part of the page, is there a way to make it work when the component is in a scrollable modal? or rather, nested within any other element that has its overflow scrollable?

@rigor789
Copy link
Owner

Yes, change the container to the scrolling container: https://github.com/rigor789/vue-scrollto#container

@ehsaneona
Copy link

hi, i set the container to my modal, but it does not work.

@jetlej
Copy link

jetlej commented Jul 10, 2021

Same problem here. Scrolling within a container does not work

@rigor789
Copy link
Owner

If you can provide a sample (jsfiddle/codesandbox etc), I can take a look - but you are most likely not setting the right container.

@GMolini
Copy link

GMolini commented Nov 30, 2022

Hi, Im also having this problem.

Ive created a codesandbox: https://codesandbox.io/s/lucid-gauss-n1fhw9?file=/src/App.vue

As you can see in the console, the element is found within the container, and the done() callback is called. But no scroll is performed.

Thank.!

@rigor789
Copy link
Owner

@GMolini the #scrollableDiv isn't actually scrollable, it's the parent element that has overflow

const container = document.getElementById("scrollableDiv");

const options = {
 container: container.parentElement
 // ...
}

// ...

That works as expected.

@GMolini
Copy link

GMolini commented Dec 1, 2022

Ok thanks! Yeah, that works.

Another thing that was happening to me is that some things on the dom that i was rendering with a v-html werent loaded by the time i was doing the scrolling. Even using $nextTick wasnt working. But doing a timeout of just 1ms has solved it.

setTimeout(function() {
   self.$scrollTo(`#${element.id}`, 1000, options);
}, 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants