You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Easing library is a comprehensive set of easing functions, useful for interactive animations and other time-based calculations where smooth transitions are necessary.
4
+
The Easing library is a comprehensive set of easing functions, useful for interactive transitions and other time-based calculations.
5
5
6
6
## Features
7
7
8
-
- Unified set of easing functions
8
+
- Unified [set](#reference) of easing functions ([])
9
9
- Easy-to-use 'swifty' API to invoke calculations
10
-
- Interpolation shorthands for the most popular primitive types like CGPoint, CGSize, CGTransform, UIColor and UIBezierPath
11
-
-Bridge to CAMediaTimingFunction
12
-
-Arbitrary cubic bezier based easings
10
+
- Interpolation shorthands for commonly used types like `CGPoint`, `CGSize`, `CGTransform`, `UIColor` and `UIBezierPath`
11
+
-Arbitrary cubic bezier based easings (see `.cubicBezier(...)`)
12
+
-Emulate default easings from iOS (see `.caEaseIn`, `.caEaseOut`, `.caEaseInEaseOut`)
13
13
- Interactive demo app
14
14
- Supports iOS 12.0+ / Mac OS X 10.13+ / tvOS 12.0+ / watchOS 4.0+ / visionOS 1.0+
15
15
16
16
## Usage
17
17
18
+
### Basic
19
+
20
+
````swift
21
+
22
+
let startValue =20.0
23
+
let endValue =60.0
24
+
let progress =0.5// Assume a progress variable that ranges from 0 to 1
25
+
26
+
let valueAtProgress = Easing.cubicEaseIn.calculate(
27
+
d1: startValue,
28
+
d2: endValue,
29
+
g: progress
30
+
)
31
+
````
32
+
18
33
### Real world example
19
34
20
35
Imagine an interaction with a `UIScrollView` where its header is fully visible when the content offset is zero and fades out completely as the content offset exceeds 100 points. You can express this behavior with the following code in your `scrollViewDidScroll` method:
The main set of easing functions is a Swift port of https://github.com/warrenm/AHEasingwhich is a port of https://github.com/ai/easings.net (https://easings.net)
132
+
The main set of easing functions is a Swift port of https://github.com/warrenm/AHEasingand https://github.com/ai/easings.net
115
133
116
134
`CubicBezierInterpolator` is a Swift port of `nsSMILKeySpline` code from Mozilla https://github.com/mozilla-services/services-central-legacy/blob/master/content/smil/nsSMILKeySpline.cpp
0 commit comments