Giter Club home page Giter Club logo

confettiview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

confettiview's Issues

SwiftUI support?

Maybe add SwiftUI wrappers? ๐Ÿ˜‰

import SwiftUI

struct ConfettiOverlay: UIViewRepresentable {
    
    typealias UIViewType = ConfettiView
    
    @Binding var isEmitting: Bool
    var particles: [ConfettiView.Content]
    var interval: TimeInterval
    
    func makeUIView(context: Context) -> UIViewType {
        let view = ConfettiView()
        return view
    }
    
    func updateUIView(_ view: UIViewType, context: Context) {
        let coordinator = context.coordinator
        if isEmitting && !coordinator.isEmitting {
            coordinator.isEmitting = true
            view.emit(with: particles, for: interval) { _ in
                coordinator.isEmitting = false
                isEmitting = false
            }
        }
    }
    
    func makeCoordinator() -> Coordinator {
        Coordinator()
    }
    
    class Coordinator {

        var isEmitting: Bool
        
        init() {
            self.isEmitting = false
        }

    }
    
}

extension View {
    
    public func confettiOverlay(isEmitting: Binding<Bool>, particles: [ConfettiView.Content], interval: TimeInterval = 3.0) -> some View {
        ZStack {
            self
            ConfettiOverlay(isEmitting: isEmitting, particles: particles, interval: interval)
                .allowsHitTesting(false)
                .accessibility(hidden: true)
        }
    }
    
}

Missing functionality

The behavior shown in the README doesn't appear possible in the current implementation. Most of the ability to customize has been closed off.

e.g. I cannot customize layers because because neither ConfettiLayer nor var confettiLayers are public/open. Was this intentionally removed or is this library simply incomplete?

In any case - is this library still "alive" enough that a PR adding the functionality would be approved?

Confetti fades out abruptly when using a duration of < 5 seconds

When emitting the confetti, using any duration less than 5 seconds causes the fading out to be very abrupt, and does not fade out like the video in the readme.

Attached is a screen recording with duration = 3s. As you can see, there is a very small fade out animation, but it generally looks very abrupt.

Untitled-2.mp4

Objective C Support

Great framework, @mattt !

I maintain an Objective C project and tried to use the framework. I imported it successfully and can create an ConfettiView object, but it doesn't have an emit method. Is it possible to use this from Objective C?

Thanks!

ConfettiView doesn't stop emitting

Hey,

I'm using this in a project and I'm facing an issue. I can't find the origin of the issue or a way to fix it properly.

After some time (seems to be when the app is running in the background and you come back to it after a while), the confettiView can't stop emitting confetti. It works great when you test several times but after a while, it seems like the CAKeyframeAnimation doesn't stop, the CATransaction completion block is never called and I'm stuck with a lot of confetti on screen ๐ŸŽ‰

The only workaround I've found so far is to launch a timer and fade out the ConfettiView myself, but it has not the same effect.

I don't know if it's the duration of the CAKeyframeAnimation or something else that gets messed up.

I also wrapped all my emit call in DispatchQueue.main.async just to make sure everything is running on the main thread but nothing does the trick so far.

I'm building on iOS 13 with Xcode 11.2.1. My emit duration is 2.0. I'm adding the ConfettiView on a UIWindow that's on top of everything else.

Any help would be appreciated.

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.