EmergeTools / Pow

Delightful SwiftUI effects for your app
https://movingparts.io/pow
MIT License
3.64k stars 153 forks source link

Adding custom phase length options for WiggleRate and ShakeRate #62

Closed mergesort closed 6 months ago

mergesort commented 7 months ago

This addresses #30, and adds the same functionality for ShakeRate.

0xifarouk commented 7 months ago

@robb any thoughts?

mergesort commented 7 months ago

Oh sorry, I'm actually the maintainer of Pow now but I've haven't gotten around to merging it in because I've been testing it in my own app before making an official release. 😅

I'll probably merge it in over the next week or two, but if you need it sooner let me know!

0xifarouk commented 7 months ago

@mergesort No worries take your time. I tried it locally but it didn't give me the desired outcome I wanted. If there is a way to wiggle less (lower the wiggle rotation angle) so it wiggles very very gently.

mergesort commented 7 months ago

Would you be able to show me the code you've tried to slow things down? When it comes to how the animation looks,, wiggle rate and the animation speed/timing.

In my case I was looking to speed up my animation, and was able to do so by lowering the phase length and increasing the animation timing. This is just an example, but you should be able to tweak the numbers and see if it works for you.

.changeEffect(
    .shake(rate: .phaseLength(0.2)),
    value: self.saveState,
    isEnabled: self.saveState == .error
)
.animation(.easeInOut(duration: 0.15), value: self.saveState)

Let me know if that works!