Giter VIP home page Giter VIP logo

jelly's Introduction

Jelly

Lighweight Viewcontroller animations with just a few lines of code

Jelly-Animators: Elegant Viewcontroller Animations in Swift

CI Status Version License Platform Twitter codebeat badge Swift 3 compatible

Jelly provides custom view controller transitions with just a few lines of code. No need to create your own Presentation-Controller or Animator objects. A Jelly-Animator will do the heavy lifting for you.

๐Ÿ“ฑ Example

You can use Jelly to build your own Alertviews or Slidein-Menus using ViewControllers designed by yourself.

Jelly-Animators: Elegant Viewcontroller Animations in Swift Jelly-Animators: Elegant Viewcontroller Animations in Swift

Jelly-Animators: Elegant Viewcontroller Animations in Swift Jelly-Animators: Elegant Viewcontroller Animations in Swift

Jelly-Animators: Elegant Viewcontroller Animations in Swift Jelly-Animators: Elegant Viewcontroller Animations in Swift

To run the example project, clone the repo, and run pod install from the Example directory first.

๐Ÿ”งHow to use

Jelly is super easy to use.

  1. Create a JellyPresentation Object
  2. Initialize a JellyAnimator using the JellyPresentation Object created in Step 1.
  3. Call the prepare(viewController:UIViewController) Function
  4. Finally call the native UIViewController presentation function.
override func viewDidLoad() {
    super.viewDidLoad()
    let viewController = self.storyboard.instantiateViewController(withIdentifier: "someViewController")
    let presentation = JellySlideInPresentation()
    self.jellyAnimator = JellyAnimator(presentation:presentation)
    self.jellyAnimator?.prepare(viewController: viewController)
    self.present(viewController, animated: true, completion: nil)
}

DO NOT FORGET TO KEEP A STRONG ๐Ÿ’ช REFERENCE

Because the transitioningDelegate of a UIViewController is weak, you need to hold a strong reference to the JellyAnimator inside the UIViewController you are presenting from or the central object that maintains your presentations.

class CustomVC : UIViewController {
    var jellyAnimator: JellyAnimator?
    override func viewDidLoad() {
        super.viewDidLoad()
        var shiftInPresentation = JellyShiftInPresentation()
        shiftInPresentation.direction = .left
        let animator = JellyAnnimator(presentation:presentation)
        self.jellyAnimator = animator
    }
}

That's it. That's lit.

๐Ÿ–Œ Customize

Jelly offers 3 types of Presentations for you:

  • JellySlideInPresentation
  • JellyShiftInPresentation
  • JellyFadeInPresentation

Not every property is available for each animation. Check outh the interfaces of each class to learn more about them.

  • duration: JellyConstants.Duration (default: normal)
    • ultraSlow = 2.0
    • slow = 1.0
    • medium = 0.5
    • normal = 0.35
    • fast = 0.2
    • reallyFast = 0.1
  • backgroundStyle: JellyConstants.BackgroundStyle (default: dimmed)
    • dimmed
    • blur(effectStyle)
    • none
  • cornerRadius: Double (default: 0)
  • corners: UIRectCorner (default: .allCorners)
    • define which corners the radius should be applied to
  • presentationCurve: JellyConstants.JellyCurve (default: linear)
    • easeIn
    • easeOut
    • easeInEaseOut
    • linear
  • dismissCurve: JellyConstants.JellyCurve (default: linear)
    • easeIn
    • easeOut
    • easeInEaseOut ย  ย * linear
  • isTapBackgroundToDismissEnabled (default: true)
    • tapping the background dismisses the ViewController by default
    • set it to false to prevent this behavior
  • widthForViewController: JellyConstants.Size (default: fullscreen)
    • If the container is smaller than the provided width, Jelly will automatically resize to the containers width
    • if Margin Guards are specified they also will be applied if width is to wide for the container
  • heightForViewController: JellyConstants.Size (default: fullscreen)
    • If the container is smaller than the provided height, Jelly will automatically resize to the containers width
    • if Margin Guards are specified they also will be applied when height is to high for the container
  • horizontalAlignment: JellyConstants.HorizontalAlignment (default: .center)
    • center, left or right
  • verticalAlignemt: JellyConstants.VerticalAlignment (default:center)
    • top, bottom, center
  • marginGuards: default(UIEdgeInsets.zero)
    • If the width or height is bigger than the container we are working with, marginGuards will kick in and limit the size using the specified margins
  • directionShow: JellyConstants.Direction (default: top)
    • left, top, bottom, right
  • directionDismiss: JellyConstants.Direction (default: top)
    • left, top, bottom, right
  • jellyness: (default: none)
    • none (damping = 1.0, velocity = 0.0)
    • jelly (damping = 0.7, velocity = 2)
    • jellier (damping = 0.5 , velocity = 3)
    • jelliest (damping = 0.2, velocity = 4)
let customPresentation = JellySlideInPresentation(dismissCurve: .linear,
                                                    presentationCurve: .linear,
                                                         cornerRadius: 15,
                                                      backgroundStyle: .blur(effectStyle: .light),
                                                            jellyness: .jellier,
                                                             duration: .normal,
                                                        directionShow: .top,
                                                     directionDismiss: .top,
                                               widthForViewController: .fullscreen, 
                                              heightForViewController: .custom(value:200) ,
                                                  horizontalAlignment: .center,
                                                    verticalAlignment: .top,
                                                         marginGuards: UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10),
                                                              corners: [.topLeft,.bottomRight])


self.jellyAnimator = JellyAnimator(presentation:customPresentation)
self.jellyAnimator?.prepare(viewController: viewController)
self.present(viewController, animated: true, completion: nil)

โœ… Requirements

Deployment target of your App is >= iOS 9.0

๐Ÿ“ฒ Installation

Jelly is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Jelly"

๐Ÿ—ฃ Mentions

๐Ÿค– Author

Sebastian Boldt, [email protected]

๐Ÿ“„ License

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

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.