Git Product home page Git Product logo

animatetext's Introduction

AnimateText for SwiftUI

This library for animating text. Developed with SwiftUI. This library supports iOS/macOS.

Platforms iOS macOS instagram SPM MIT

Screenshot

AnimateText.mp4

Example

https://fabulaapp.page.link/224

Usages

  1. AnimateText

    /// A view that animates binding text. Passing the effect type as a generic.
    /// struct AnimateText<E> where E : ATTextAnimateEffect
    /// Binding the text to be expressed.
    @State var text: String = "AnimateText"
    
    /// The type used to split text.
    @State var type: ATUnitType = .letters
    
    /// Custom user info for the effect.
    @State var userInfo: Any? = nil
    
    AnimateText<CustomEffect>($text, type: type, userInfo: userInfo)
  2. Each effect only needs to conform to the ATTextAnimateEffect protocol.

    /// Custom animation effect.
    public struct CustomEffect: ATTextAnimateEffect {
    
        public var data: ATElementData
        public var userInfo: Any?
    
        public init(_ data: ATElementData, _ userInfo: Any?) {
            self.data = data
            self.userInfo = userInfo
        }
    
        public func body(content: Content) -> some View {
            content
                .opacity(data.value)
                .animation(.easeInOut.delay(Double(data.index) * 0.06), value: data.value)
        }
    }
  3. ATTextAnimateEffect protocol

    /// A protocol to implement text animation effects.
    public protocol ATTextAnimateEffect: ViewModifier {
    
        /// Informational data required for each element animation.
        var data: ATElementData { get }
        /// Custom user info for the effect.
        /// The effect maintains a strong reference to this object until it (the effect) is invalidated. This parameter may be nil.
        var userInfo: Any? { get }
    
        init(_ data: ATElementData, _ userInfo: Any?)
    }

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding AnimateText as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/jasudev/AnimateText.git", .branch("main"))
]

Contact

instagram : @dev.fabula
email : [email protected]

License

AnimateText is available under the MIT license. See the LICENSE file for more info.

animatetext's People

Contributors

jasudev avatar tlacan avatar

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.