Comments (16)
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.
I'm trying to activate the pulse on a longtap gesture and remove the pulse when the touch is released.
from swiftpulse.
Do I call removeAllAnimations on the layer it's attached to or the actual imageView? Also, how would I reattach? .insertSublayer?
from swiftpulse.
Thanks for getting back to me so fast btw.
from swiftpulse.
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.
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.
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.
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.
Exiting and entering the app again makes it work, could be a lead
from swiftpulse.
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.
I've tried that as well, same effect :(
from swiftpulse.
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.
Thanks for helping out. I'll try that.
from swiftpulse.
Simple CALayer behaves the same...
from swiftpulse.
Figured it out!!!! One of my other animations was interfering with it for some reason.
from swiftpulse.
Happy that you could resolve the problem! Happy coding!
from swiftpulse.
Related Issues (11)
- Failing during initialization HOT 5
- Add Pod Support
- support marker google map?
- Background thread UI violation in iOS 14
- Use of unresolved Identifier 'Async' in LFTPulseAnimation.swift File HOT 2
- Can't get it to work HOT 1
- Any extra tips on how to use it? HOT 4
- How can I use with auto-layout? HOT 1
- Add more layer HOT 1
- How do i make a pulse like the one on the readme with multiple pulses? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftpulse.