mdbootstrap / perfect-scrollbar

Minimalistic but perfect custom scrollbar plugin. Get more free components with Material Design for Bootstrap UI Kit (link below)
https://perfectscrollbar.com/
MIT License
346 stars 66 forks source link

getInstance function #116

Open kkaplita opened 6 years ago

kkaplita commented 6 years ago

I would like to get instances of PerfectScrollbar by select element. In my project perfect scrollbar is initialized in many views and I want to get all instances in mainView to update etc.

GufNZ commented 6 years ago

You could also manage your own collection of instances as you create them.

DarkCompiled commented 4 years ago

I would also be interested in this feature. Some libraries create the scrollbar themselves, so we cannot control, for example, the options. :slightly_frowning_face:

It can be something like: $el.data("jq.PerfectScrollbar")

Or something like: $el.PerfectScrollbar

I would also enjoy a way to override the options, especially the "handlers", but if I have the instance, I can always destroy and create another.

f135ta commented 4 years ago

Bump .. I have the same requirement for this

f135ta commented 4 years ago

I'm using JQuery, and i've been able to solve this using the JQuery caching feature.

const ps = new PerfectScrollbar(elementName,
{
    wheelSpeed: 0.2,
    swipeEasing: true,
    wheelPropagation: propagateScrolling,
    minScrollbarLength: 20,
    maxScrollbarLength: 150
});

// Store the Perfect Scrollbar Instance for later
$(elementName).data("ps-" + elementName, ps);

Then in my "update" method, I just fetch the instance from the cache and call ".update" like this

var ps = $(elementName).data("ps-" + elementName);
if (ps !== null) {
     ps.update();
}

@DarkCompiled - I dont think it'll help with your problem of not being able to get to instances created by third parties though..

ferrykranenburgcw commented 3 years ago

We have the same requirement, but this issue is open for a long time. Is it not going to happen?