YapAnimator is your fast and friendly physics-based animation system

Overview

YapAnimatorLogo

YapAnimator is your fast and friendly physics-based animation system. YapAnimator was built with ease-of-use in mind, keeping you sane and your designer very, very happy. All animations are interruptable, include completion blocks, and allow you to apply forces to them (e.g. adding the velocity from a gesture in a transition). We've included Animatable protocol conformance for some commonly animated types (CG types), but it's really easy to add conformance to any other type. You can animate anything that you can represent and compose with an array of Doubles — view properties, music volume, morphing between bezier paths, colors, smoothing brush strokes, the list goes on… use your imagination!

Build Status CocoaPods Compatible Platform

Why use YapAnimator?

Because it's insanely easy to use and makes beautiful animations, that's why. There are other physics-based animation systems out there (e.g. UIKit's spring animations, Facebook's Pop), but they still require writing too much code, bookkeeping, and hand-holding for our taste. YapAnimator represents a distilled n-th iteration of code that we've been using in our own apps for years. We find it invaluable in our day-to-day and think that you will too.

Built-in Extensions

YapAnimator comes with a handy extension bolted on to CALayer and UIView/NSView, providing one-liner animations under the animatedLayer and animated properties, respectively.

CircleAnimationExample

func handle(gesture: UIPanGestureRecognizer) {

	if gesture.state == .began {
		squircle.animated.cornerRadius.animate(to: squircle.bounds.width / 2.0)
		squircle.animated.rotationZ.animate(to: .pi)
	else if gesture.state == .changed {
		squircle.animated.position.instant(to: gesture.location(in: nil))
	} else if gesture.state == .ended {
		squircle.animated.position.animate(to: self.view.center)
		squircle.animated.cornerRadius.animate(to: 0)
		squircle.animated.rotationZ.animate(to: 0)
	}
}

Custom Animators

Creating a custom animator is straightforward:

  • initialValue This sets the initial value of the animator and informs it what type it will be animating.
  • willBegin Called just before motion starts. Return the actual value of the property that you'll be animating. This allows the animator to sync up with that value in case it was changed outside of the scope of the animator. (optional)
  • eachFrame Called each frame of the animation — this is typically where you'd apply the animator's current.value to the property that you're animating. You can also use it to check values to trigger other actions / animations.
frameAnimator = YapAnimator(initialValue: square.frame, willBegin: { [unowned self] in
	return self.square.frame
}, eachFrame: { [unowned self] (animator) in
	self.square.frame = animator.current.value
})

SquareFrameExample

frameAnimator.bounciness = 1.5

frameAnimator.animate(to: square.frame.insetBy(dx: -50, dy: -50), completion: { animator, wasInterrupted in
	if !wasInterrupted {
		// animate back to the original value
		animator.animate(to: animator.current.value.insetBy(dx: 50, dy: 50))
	}
})

Questions?

Feel free to ask your question in an issue. We will respond there, and amend this read me/start a wiki if the answer seems like it would benefit others.

Credits

YapAnimator is owned and maintained by Yap Studios.

You might also like...
MobilePillowTalkLite - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution Gemini is rich scroll based animation framework for iOS, written in Swift.
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Anima is chainable Layer-Based Animation library for Swift5.
Anima is chainable Layer-Based Animation library for Swift5.

Anima Anima is chainable Layer-Based Animation library for Swift5. It support to make sequensial and grouped animation more easily. is written as foll

Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Designed for gesture-driven animations. Fast, simple, & extensible!
Designed for gesture-driven animations. Fast, simple, & extensible!

Yet Another Animation Library Designed for gesture-driven animations. Fast, simple, & extensible! It is written in pure swift 3.1 with protocol orient

Sample way of integrating animations into a design system for iOS app projects.

Animations in Design System The project presents a sample way of integrating animations into a design system for iOS developers. Project setup A sampl

Design-system-demo - This example code is bare-bones to show you what this framework can do

Basic Style Dictionary This example code is bare-bones to show you what this fra

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Comments
  • macOS Support

    macOS Support

    Loved the size & simplicity of the framework, and noticed it wasn't too far off from being able to support Mac in a very similar way. Sense the Mac is a bit farther behind on being able to do these kinds of animations easily like on iOS, this proves pretty useful.

    Tried my best to not change any behavior, while keeping the code the same as much as possible.

    opened by samleegray 3
  • NSColor.ColorType build error on macOS with Swift 4

    NSColor.ColorType build error on macOS with Swift 4

    Base SDK 10.13 ~~ no other available Target 10.12 ~~ changing target to anything else (including 10.13) does not seem to make a difference.

    On YapAnimator | Animatable.swift at build-time line 236: guard let ci = CIColor(color: self) else { return Array<Double>(repeating: 0, count: type(of:self).count) } type seems to be at fault. Cannot call value of non-function type 'NSColor.ColorType'

    Any ideas?

    opened by dnsmob 2
  • Control duration of animation?

    Control duration of animation?

    Is it possible to change the duration length of the animation? From a quick glance it seems like YapAnimator calculates a nice duration based on the bounciness and speed, right?

    opened by saoudrizwan 1
  • Support MacOS

    Support MacOS

    Dear Author, I found your code did not support MacOS as you described, UIKit / UITextField is for iOS, not for MacOS, have you tried MacOS? May i have your update for supporting MacOS?

    opened by ArthurXu424 0
Owner
Yap Studios
Yap Studios is a digital development agency located in Silicon Valley. We craft incredible apps for leading brands worldwide.
Yap Studios
Physics-based animations for iOS, tvOS, and macOS.

Advance An animation library for iOS, tvOS, and macOS that uses physics-based animations (including springs) to power interactions that move and respo

Tim Donnelly 4.5k Dec 29, 2022
Friendly reminder that you're not gonna live forever

Life Progress Friendly reminder that you're not gonna live forever How it works Each row represents a year of your life. Each square represents a week

Tien Pham 188 Dec 22, 2022
A Fast Animation Engine with an Intuitive API

Kinieta An Animation Engine for iOS with an Intuitive API and Readable Code! (Written in Swift 4.0.) Why another? I decided to build an Animation Engi

Michael Michailidis 44 Sep 22, 2022
Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers. It's magic. Features Animate a

Robert-Hein Hooijmans 1.3k Nov 17, 2022
A simple spritesheet animation system for Raylib on Swift.

About A simple spritesheet animation system for Raylib on Swift. Aeni allows you to quickly and easily animate your spritesheet in your Raylib for Swi

Conifer 8 Oct 14, 2022
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023