Open ghost opened 6 years ago
IM not sure if scroll-magic is being maintained anymore??? On another note, many people talk about reducing resource intense etc but and this maybe controversial but machines are getting faster and can process things in hardly anytime so why bother making code super slick?
Ok, yes it needs to be to an extent but not as much as it was in the past and many coders strive for days, weeks etc trying to make sublime code when in reality, the processing speed of even a basic mobile can handle a lot nowadays
@jwmcgavin You're animating some expensive properties like background-position
or padding
, try only animating with opacities and transforms instead and cache all relevant layers with will-change: transform
.
@BadgersNadgers It's not controversial, it's naive.
@mystrdat I was chatting with Jack from Greensock the other day and he was saying to not use will-change just now as it's a minefield and could cause more issues than it solves.
@mystrdat https://greensock.com/will-change
@petebarr I've had success using it for transforms that do not scale or caching position fixed layers without transformations, to a large degree it seems to work like transform: translate3d(0)
. Despite the implementation complexity, they still recommend using it for transforms past Chrome 53:
Make sure to set will-change: transform if you're animating transforms and want to opt-in to performance optimizations and avoid jittery background-image scaling. But be careful about how it might affect stacking contexts, and keep checking when other browsers decide to implement will-change, as it could change how your content looks.
The stacking context problem is something Webkit broke back in the day when positions and transforms started always establishing contexts, it makes sense that the property creates its own too. I feel like the problem shows itself properly only if you start scaling elements above 1
.
@mystrdat hardly naive, most mobiles can handle plenty nowadays, working out the load you need to use is key, order of events. Have used load distribution etc for many years, no problems so not naive, tried and tests hundreds of times. Plan the project well so you can animate background images, use padding animation as-well no need to avoid them if you've planned properly, its naive not to.
@BadgersNadgers I'm afraid you're making sweeping statements about a complex system where one mechanism can perform really fast and the other not so much. That is the case with padding
in HTML rendering, which modifies the element box model and triggers a recalculate for every update of the property.
Especially in more than simple demo cases, the performance will be far away from using transforms, which is instead a cached texture processed by the GPU. This is a complex topic overall, I suggest you do some research on animatable style properties, perhaps in comparison to canvas and WebGL animation. It is hard to make a HTML UI fly, even more so on mobile and Cordova-wrapped apps.
Complexity of performance in a HTML UI is the reason Facebook failed to deliver a good HTML5 experience back in the day: https://news.ycombinator.com/item?id=4507879
I'm afraid I have to agree with @BadgersNadgers, try animating a border thickness and you can see how poor the animation experience is. Check this out as a frame of reference: https://css-tricks.com/animating-border/ . You can achieve so much with transforms, scale and opacity that I rarely go near anything else for UI animation, sometimes a height here or there but I try to avoid it if at all possible.
@petebarr Either you swapped the nicknames or I'm lost in the debate :suspect:
I meant you @mystrdat lol! Sorry, brain is firing on 50% with the late nights of a deadline.
I've used ScrollMagic on my portfolio site to animate the positions of various images. But the animations are somewhat clunky.
Here's the relevant js. How can I make the animations smoother and less resource-intensive?