Share Posted October 14, 2021 Hi all, I am trying to solve issue with Draggable. I run performance test on my site and I am able to see rendering tasks on main-thread, but page should be in idle state. I know GSAP has something like autoSleep but it seems that this not work for Draggable. Browser is doing uneccessary work. On weaker computers fan is running and on mobile devices the batery is warming and consuming. Is there any way how to impove it? I tryied .disable method but it not help. Thanks for help. Link to comment Share on other sites More sharing options...
Share Posted October 14, 2021 My best guess (without a minimal demo) is that it's InertiaPlugin, because you have inertia: true. That plugin must constantly track the properties (typically "x" and "y") to know their velocity at any given time. You can enable/disable that using the InertiaPlugin.track() and untrack() methods: InertiaPlugin.track("#element", "x,y"); InertiaPlugin.untrack("#element", "x,y"); Other than that, yes, GSAP will eventually autoSleep when there haven't been any GSAP animations for a while. Even if it didn't sleep, that wouldn't take up much processing at all. It's super cheap. So if your device's fans kick on, you've almost surely got something else going on that's not just GSAP or Draggable being idle. 1 Link to comment Share on other sites More sharing options...
Author Share Posted October 22, 2021 @GreenSock thanks for replay. I understand how inertia works but I expected that it tracks only if draggable is actived = dragStart event is fired. Is it safe manipulate with InertiaPlugin when Draggable handles it internally? If yes i will do it in callbacks. Link to comment Share on other sites More sharing options...
Share Posted October 23, 2021 In order for the inertia calculations to be accurate, it must have at least a few hundred milliseconds of historical data to deal with. That's why InertiaPlugin keeps tracking the value(s) - there's no way to know exactly when the user is going to drag so that it can start recording beforehand adequately. But yeah, you can manually track()/untrack() if you're confident you can do it at least about a half-second before the properties start changing 1 Link to comment Share on other sites More sharing options...
Author Share Posted October 23, 2021 @GreenSock Ok, thanks for you time. I will combine it with IntersectionObserver. It should work well. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now