vue-scrollto icon indicating copy to clipboard operation
vue-scrollto copied to clipboard

Scrolling within a modal

Open AbrahamBrookes opened this issue 5 years ago • 7 comments
trafficstars

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?

AbrahamBrookes avatar Jun 22 '20 04:06 AbrahamBrookes

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

rigor789 avatar Jun 22 '20 17:06 rigor789

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

ehsaneona avatar Feb 27 '21 07:02 ehsaneona

Same problem here. Scrolling within a container does not work

jetlej avatar Jul 10 '21 16:07 jetlej

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

rigor789 avatar Jul 10 '21 20:07 rigor789

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.!

GMolini avatar Nov 30 '22 12:11 GMolini

@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.

rigor789 avatar Nov 30 '22 19:11 rigor789

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);

GMolini avatar Dec 01 '22 07:12 GMolini