SkillAgentSearch skills...

Gemini

Gemini is rich scroll based animation framework for iOS, written in Swift.

Install / Use

/learn @shoheiyokoyama/Gemini

README

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/logo.png" width="500"> </p>

Overview

<img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/demo-circle-rotation.gif" align="left">

What is the Gemini?

Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which is a subclass of UICollectionView.

It enables you to make multiple animation which has various and customizable properties, and moreover can create your own custom scroll animation.

Gemini also provides a fluent interface based on method chaining. you can use this intuitively and simply.

collectionView.gemini
    .circleRotationAnimation()
    .radius(400)
    .rotateDirection(.clockwise)

Features

Platform Cocoapods Carthage compatible License Swift pod

<img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/demo-yaw-rotation.gif" align="right">
  • [x] Rich animation with scrolling
  • [x] Easily usable
  • [x] Highly customizable
  • [x] Several types of animations and properties
  • [x] Supports vertical and horizontal flow layout
  • [x] Supports easing function
  • [x] Supports Swift5.0
  • [x] Fluent interfaces based on method chaining
  • [x] Compatible with Carthage
  • [x] Compatible with CocoaPods
  • [x] Example project with lots of stock animations
  • [x] And More...

Contents

<a name="animation-types"> Animation Types and properties

The following animation types are available. See sample code here for details.

In addition, you can also customize the following properties for the above animation types.

<a name="cube"> Cube

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/cube-horizontal.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/cube-vertical.gif"> </p>

It's a cube animation like Instagram. If you would like to customize the cube animation, change cubeDegree. If cubeDegree is 90, it moves like a regular hexahedron.

collectionView.gemini
    .cubeAnimation()
    .cubeDegree(90)

<a name="circle-rotation"> CircleRotation

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/circle-horizontal.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/circle-vertical.gif"> </p>

An animation moves in a circle. You can change circleRadius and CircleRotationDirection.

collectionView.gemini
    .circleRotationAnimation()
    .radius(450) // The radius of the circle
    .rotateDirection(.clockwise) // Direction of rotation. 
    .itemRotationEnabled(true) // Whether the item rotates or not.

<a name="3d-vector-rotation"> 3D vector rotation

Available for Roll, Pitch and Yaw animation. These rotation animation are designed based on 3-Dimensional vector. Figure-1 shows direction of rotation based on device.

Figure-1 Pitch, roll, and yaw axes
<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/attitude_rotation.png" width="350"> </p>
Reference: Event Handling Guide for UIKit Apps

<a name="roll-rotation"> Roll Rotation

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/roll-horizontal.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/roll-vertical.gif"> </p>

<a name="pitch-rotation"> Pitch Rotation

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/pitch-horizontal.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/pitch-vertical.gif"> </p>

<a name="yaw-rotation"> Yaw Rotation

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/yaw-horizontal.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/yaw-vertical.gif"> </p>

Each types of rotation animation has RotationEffect(e.g. RollRotationEffect) and degree of rotation.

Customize RotationEffect (up, down, sineWave, reverseSineWave) and degree of rotation.

In the case of rollRotation, like this:

collectionView.gemini
    .rollRotationAnimation()
    .degree(45)
    .rollEffect(.rollUp)

<a name="scale"> Scale

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/scale-up.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/scale-down.gif"> </p>

The scaleUp gradually increases frame size, scaleDown decreases.

collectionView.gemini
    .scaleAnimation()
    .scale(0.75)
    .scaleEffect(.scaleUp) // or .scaleDown

<a name="custom"> Custom

<p align="center"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/custom1.gif"> <img src="https://github.com/shoheiyokoyama/Assets/blob/master/Gemini/custom2.gif"> </p>

You can flexibly and easily customize scroll animation. Customize properties of GeminiAnimation.custom such as scale, scaleEffect, rotationAngle, translation, easing, shadowEffect, alpha, cornerRadius, backgroundColor, anchorPoint, etc.

The animation of gif is customized in the following way:

collectionView.gemini
    .customAnimation()
    .translation(y: 50)
    .rotationAngle(y: 13)
    .ease(.easeOutExpo)
    .shadowEffect(.fadeIn)
    .maxShadowAlpha(0.3)

Or right side of gifs is customized as follows:

collectionView.gemini
    .customAnimation()
    .backgroundColor(startColor: lightGreenColor, endColor: lightBlueColor)
    .ease(.easeOutSine)
    .cornerRadius(75)

There are more sample code at CustomAnimationViewController.swift.

<a name="easing-function"> Easing function

Gemini supports various easing functions based on distance of scroll.

  • linear
  • easeInQuad
  • easeOutQuad
  • easeInOutQuad
  • easeInCubic
  • easeOutCubic
  • easeInOutCubic
  • easeInQuart
  • easeOutQuart
  • easeInOutQuart
  • easeInQuint
  • easeOutQuint
  • easeInOutQuint
  • easeInSine
  • easeOutSine
  • easeInOutSine
  • easeInExpo
  • easeOutExpo
  • easeInOutExpo
  • easeInCirc
  • easeOutCirc
  • easeInOutCirc

<a name="shadow-effect"> Shadow effect

Default value is ShadowEffect.none. Return shadowView in your custom class, which is a subclass of GeminiCell.

  • fadeIn
  • nextFadeIn
  • previousFadeIn
  • fadeOut
  • none
class CustomCollectionViewCell: GeminiCell {
    @IBOutlet weak var customShadowView: UIView!
    override var shadowView: UIView? {
        return customShadowView
    }
}

<a name="usage"> Usage

  1. Use Gemini classes

Gemini is designed to be easy to use. Use GeminiCollectionView and GeminiCell. These classes is subclass of UICollectionView, UICollectionViewCell.

  1. Configure animation

Configure animation with fluent interface based on method chaining. You can develop expressive code that enhances readability.

  1. Call function for animation

Finally, call animateVisibleCells() in scrollViewDidScroll(_:)

NOTE: If you want to adapt animation immediately after view is displayed, call animateCell(_:) in collectionView(_:cellForItemAt:) and collectionView(_:willDisplay:forItemAt:).

// Import Gemini
import Gemini

// Inherite GeminiCell
class CustomCell: GeminiCell {
    ...
}

// Conform to UICollectionViewDelegate and UICollectionViewDataSource
class CustomViewController: UIViewController: UICollectionViewDelegate, UICollectionViewDataSource {

    // Inherite GeminiCollectionView
    @IBOutlet weak var collectionView: GeminiCollectionView!

    ...

    // Configure animation and properties
    func configureAnimation() {
        collectionView.gemini
            .circleRotationAnimation()
            .radius(400)
            .rotateDirection(.clockwise)
    }

    // Call animation function
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        collectionView.animateVisibleCells()
    }

    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        if let cell = cell as? GeminiCell {
            self.collectionView.animateCell(cell)
        }
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt ind

Related Skills

View on GitHub
GitHub Stars3.3k
CategoryDevelopment
Updated8d ago
Forks199

Languages

Swift

Security Score

100/100

Audited on Mar 17, 2026

No findings