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
Slow performance due to animations #23
Comments
Good day! I need a few more infos from you:
It would be really great if you could provide a small demo on jsfiddle. |
To answer a few of your questions:
I have posted this problematic build using these params: I am using now sizeAutoCapable: false as that seems to resolve the problem even though not really super smooth but it will work but I would like for you to regardless take a look as your scroller is pretty nice. Here's the deployed site. Inspect it as mobile. |
Thank you for the answers! - I'll definitely investigate at this problem. |
Oops sorry.. staging.hingecapital.com |
I think the sizeAutoCapable: false works well enough. I have to push the new update that performs a lot better. I think you can close this but definitely try to investigate this sizeAutocapable: true and multiple elements that are assigned to overlayScrollbars initialization. Something is definitely making it super slow. Thanks. |
Alright, I've took a look at your site and I think I've figured out what the problem is. The plugin already provides a solution for this case. The Now the plugin is watching the DOM and if the DOM has changed in a certain way the plugin is thinking it has to update itself because of those changes. Since you're animation the DOM with JavaScript, it changes constantly over the whole animation period. Thats okay on one or two instances but if you've more instances this scenario can get quite slow and you have to tell the plugin on which changes it has to update and on which not. The plugin offers a sleep method. This method was specially designed for such cases and tells the plugin to stop updating the DOM by itself. The plan is now, that you put all instances to sleep if they're not needed or beeing animated until the animations are completed. It's actually quite easy to do so, since your code is well structured. All you have to do is to optimize the This is how the afterLoad: function (anchorLink, index) {
var loadedSection;
loadedSection = $(this);
/* OverlayScrollbars-Fix: Put all the instaces in this section to sleep */
var osInstances = loadedSection.find('.overlayScroll').overlayScrollbars();
$.each(osInstances, function(index, value) {
if(value.sleep)
value.sleep();
});
if (index == 2)
showCollective();
if (index == 3)
showCompany();
if (index == 4)
showData();
if (index == 5)
showReserves();
if (index == 6)
showContact();
/* OverlayScrollbars-Fix: wake all the instances in this section up */
setTimeout(function() {
$.each(osInstances, function(index, value) {
if(value.update)
value.update();
});
}, /* the average timespan in ms after all animations are completed - for example 1000 */ 1000);
} I hope you've got the idea. You can optimize the Please try this fix and tell me if its working. Please also use |
So, everything works great up until I have about 10 or more elements on page that are initialized by OverlayScrollbar instance.
I have sections across the site and when I get to about 10 or more the OverlayScrollbar slows down drawing of elements and the wait is about 10-20 seconds before elements shows up. It's like CPU gets overloaded until it executes and initializes all elements and then it starts working. Something is going on under the hood with a bunch of divs using the OverlayScrollbar.
This is how I initialize:
$('.overlayScroll').overlayScrollbars({ className : "os-theme-dark", resize : "none", sizeAutoCapable : true, paddingAbsolute : true, overflowBehavior: { x: "hidden" }, });
Each area I want to make scrollable has this format:
<div class="section-content overlayScroll"> <div class="overlayScrollContent"> <div class="inner-title">Some title</div> <div class="inner-content">Some content text</div> </div> </div>
Everything works ok up to maybe 8-10 or so elements but then suddenly everything slows down to a crawl. One thing to note is that I'm using flexbox for most elements.
The text was updated successfully, but these errors were encountered: