Git Product home page Git Product logo

Comments (16)

ctews avatar ctews commented on July 29, 2024

Hey junhohong,

what exactly do you try to achieve? There are several ways to do so or fake that effect. Currently I have no pause and resume method implemented. But you could set the alpha of the animation to zero, set it to hidden, removeAllAnimations of the element that uses that and reattach it again. I can try to implement pause and resume if I get some free time, but won't be able to do it quickly.

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

I'm trying to activate the pulse on a longtap gesture and remove the pulse when the touch is released.

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Do I call removeAllAnimations on the layer it's attached to or the actual imageView? Also, how would I reattach? .insertSublayer?

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Thanks for getting back to me so fast btw.

from swiftpulse.

ctews avatar ctews commented on July 29, 2024

Cannot test it in person right now but the whole thing is a subclass of CALayer. So if you keep a reference to the pulsing CALayer you should be able to remove that specific layer from the view it's lying on. Basically on touchRelease you could do pulseReference.removeFromSuperLayer.

That's a guess in the wild, but should work in theory. Let me know!

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

I've actually tried that and it does successfully remove the pulse. However my problem is starting up the animation again - I've tried initializing the animation again and inserting it to the sublayer, keeping the same animation and inserting it to the sublayer -- both did not work :(

from swiftpulse.

ctews avatar ctews commented on July 29, 2024

That's weird. Could you attach a code example? I would think at least reinirializing it again and add it as a sublayer should work properly.

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

On longhold:

let pulseEffect = LFTPulseAnimation(repeatCount:Float.infinity, radius:60, position: CGPoint(x:pulseView.frame.width/2,y:pulseView.frame.height/2))
pulseView.layer.insertSublayer(pulseEffect, below: pulseView.layer)

On release:
pulseView.layer.sublayers?.forEach{$0.removeFromSuperlayer()}

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Exiting and entering the app again makes it work, could be a lead

from swiftpulse.

ctews avatar ctews commented on July 29, 2024

could you please try the following:

Save the reference to the pulse effect and then do the following:
On release:
pulseEffect.removeFromSuperLayer()

So don't traverse through layer hierarchy and remove every sublayer but just the pulseEffect layer.

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

I've tried that as well, same effect :(

from swiftpulse.

ctews avatar ctews commented on July 29, 2024

I am on the run so can't look deeper into it. But it's a standard CALayer, whatever is wrong there should also not work with a normal CALayer. Did you try it with a simple CALayer if it behaves the same?

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Thanks for helping out. I'll try that.

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Simple CALayer behaves the same...

from swiftpulse.

junhohong avatar junhohong commented on July 29, 2024

Figured it out!!!! One of my other animations was interfering with it for some reason.

from swiftpulse.

ctews avatar ctews commented on July 29, 2024

Happy that you could resolve the problem! Happy coding!

from swiftpulse.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.