Giter Club home page Giter Club logo

valueanimator's Introduction

ValueAnimator

Version License Platform codebeat badge actions workflow

  • Multiple properties in funcion 'onChanged'

Demo

Demo for UIView animation

Usage

ValueAnimator makes the transition from initial value to target value using easing functions.

Simple animation

let animator = ValueAnimator.animate("some", from: 0, to: 360, duration: 1.0,
    onChanged: { p, v in 
        print("property \(p): \(v.value)")
    },
    easing: EaseCircular.easeIn())
animator.resume()

Yoyo annimation with 2 values

let yoyoAni = ValueAnimator.animate(
    props: ["h", "w"], 
    from: [20, 30], 
    to: [5, 150], 
    duration: 1.4, 
    easing: EaseSine.easeInOut(), 
    onChanged: { p, v in
        if p == "h" {
            let width = self.rect1.bounds.width
            self.rect1.frame = CGRect(x: 24, y: 140, width: width, height:v.cg)
        } else {
            let height = self.rect1.bounds.height
            self.rect1.frame = CGRect(x: 24, y: 140, width:v.cg, height: height)
        }
    }, 
    option: ValueAnimator.OptionBuilder()
        .setYoyo(true)
        .build())
yoyoAni.resume()

Thread

ValueAnimator uses its own work-thread. But the callback changeCallback, endCallback is called in main-thread. if you wanna it called in work-thread, you just set the 'callbackOnMainThread' property is false.

let someView: UIView!
let animator = ValueAnimator.animate("some", from: 0, to: 1, duration: 1.0,
    onChanged: { p, v in 
        // called in ValueAnimator's work-thread
    },
    easing: EaseCircular.easeIn())
animator.callbackOnMainThread = false
animator.resume()

Example

To run the example project, clone the repo, and run open ValueAnimator.xcworkspace. You can see ValueAnimatorExample project.

Installation

  • Open Xcode
  • Go to File > Swift Packages > Add Package Dependency...
  • Paste this Github Repo URL (https://github.com/brownsoo/ValueAnimator) into the search bar.
  • Select the ValueAnimator repo from the search results.

Simply add the following line to your Podfile:

pod 'ValueAnimator'

Author

brownsoo, @medium

License

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

valueanimator's People

Contributors

brownsoo avatar

Stargazers

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

Watchers

 avatar  avatar

valueanimator's Issues

Intermittent crashes - onProgress()

Hi,

I sometimes get crashes when animating a value. bad exec error at onProgress() method

Firebase crash report:

CoreFoundation
-[NSOrderedSet initWithSet:copyItems:]

The requirements to reproduce the error is unknown.

Breakpoint:
while aniList.count > 0 //line 256 on ValueAnimator.swift

It's got something to do with aniList set

animate의 onChanged

안녕하세요. 좋은 라이브러리 감사드립니다.

animate의 onChaned 에서
value값 대신 애니메이션의 진척률을 알아올 순 없나요?

Error @available

Xcode 15 and Swift 5.9 don't allow to use this syntax for stored properties.

file: ValueAnimatorSwift
lines: 116 & 121
@available(swift, obsoleted: 0.6.3, renamed: "changeCallback")

Xcode 12 GM version issue

image

안녕하세요. xcode 12 gm 버전 관련해서 문의드립니다.
해당 버전으로 빌드를 돌렸는데, 위와 같이 컴파일 에러가 발생합니다.
라이브러리 버전을 업데이트 해도 동일한 증상 발생하구요.
확인 부탁드리겠습니다. 감사합니다.

Invalid `ValueAnimator.podspec` file when trying to pod install something that requires ValueAnimator

$ pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /Users/marty/node_module_collections/default/bin in PATH, mode 040777
Analyzing dependencies
Pre-downloading: `BlueSocket` from `https://github.com/IBM-Swift/BlueSocket.git`, branch `master`
Pre-downloading: `CTShowcase` from `https://github.com/scihant/CTShowcase.git`, branch `master`
Pre-downloading: `CocoaAsyncSocket` from `https://github.com/robbiehanson/CocoaAsyncSocket.git`, branch `master`
Pre-downloading: `MMLanScan` from `https://github.com/mavris/MMLanScan.git`, branch `master`
Pre-downloading: `TriLabelView` from `https://github.com/mukeshthawani/TriLabelView.git`, branch `master`
Pre-downloading: `ValueAnimator` from `https://github.com/brownsoo/ValueAnimator.git`, branch `master`
[!] Failed to load 'ValueAnimator' podspec: 
[!] Invalid `ValueAnimator.podspec` file: undefined method `swift_versions=' for #<Pod::Specification name="ValueAnimator">
Did you mean?  swift_version=
               swift_version.

 #  from /var/folders/xj/t4w3l34124g6bxv455kt25ph0000gn/T/d20200203-37282-f9je70/ValueAnimator.podspec:20
 #  -------------------------------------------
 #    s.source_files     = 'ValueAnimator/**/*.swift'
 >    s.swift_versions = ['4.0', '4.2', '5.0']
 #  end
 #  -------------------------------------------

This is my Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

target 'ScichartTestProject' do
    pod 'CocoaAsyncSocket', :git => 'https://github.com/robbiehanson/CocoaAsyncSocket.git', :branch => 'master'
    pod 'TTGSnackbar' #update to version 1.7.5 causes unkown selector exception
    pod 'TriLabelView', :git => 'https://github.com/mukeshthawani/TriLabelView.git', :branch => 'master'
    pod 'MMLanScan', :git => 'https://github.com/mavris/MMLanScan.git', :branch => 'master'
    pod 'ValueAnimator', :git => 'https://github.com/brownsoo/ValueAnimator.git', :branch => 'master'
    pod 'BlueSocket', :git => 'https://github.com/IBM-Swift/BlueSocket.git', :branch => 'master'
    pod 'CTShowcase', :git => 'https://github.com/scihant/CTShowcase.git', :branch => 'master'
end

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.