Giter Site home page Giter Site logo

ivfomenko / jelly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sebastianboldt/jelly

1.0 0.0 0.0 53.99 MB

๐ŸŒŠ - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.

Home Page: http://www.sebastianboldt.com/

License: MIT License

Swift 98.34% Ruby 1.66%

jelly's Introduction

Jelly-Animators: Elegant Viewcontroller Animations in Swift

current version current version twitter handle Swift 4.2 compatible platform carthage support license

Jelly is a library for animated, non-interactive & interactive viewcontroller
transitions and presentations with the focus on a simple and yet flexible API.

With a few lines of source code, interactive UIViewController transitions
and custom resizable UIViewController presentations can be created,
without the use of the cumbersome UIKit Transitioning API.

var slidePresentation = SlidePresentation(direction: .left)
let animator = Animator(presentation: slidePresentation)
animator.prepare(viewController: viewController)
present(viewController, animated: true, completion: nil)

  1. Create a Presentation Object
  2. Configure an Animator with the Presentation
  3. Call the prepare Function
  4. Use the native UIViewController presentation function.
class ViewController : UIViewController {
    var animator: Jelly.Animator?
    override func viewDidLoad() {
        super.viewDidLoad()
        let viewController = YourViewController()
        let presentation = SlidePresentation(direction: .left)
        animator = Animator(presentation:presentation)
        animator?.prepare(presentedViewController: viewController)
        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 Animator inside the UIViewController you are presenting from or the central object that maintains your presentations.

Interactive transitions can be activated for the slide and the cover transitions. If the transitions are to be interactive, only an InteractionConfiguration object has to be passed to the presentation.

Here 3 parameters play an important role. First, the completionThreshold, which determines the percentage of the animation that is automatically completed as soon as the user finishes the interaction. The second parameter is the actual type of interaction. Jelly offers the .edge and the .canvas type. In an .edge transition, the user must execute the gesture from the edge of the screen. When using the .canvas type, gesture recognizers are configured so that direct interaction with the presenting and presented view leads to the transition. The last parameter is called mode. Using the mode you can limit the interaction to presentation or dismiss interaction (default = [.present,.dismiss]).

let viewController = YourViewController()
let interaction = InteractionConfiguration(presentingViewController: self, completionThreshold: 0.5, dragMode: .edge, mode: .dismiss)
let presentation = SlidePresentation(direction: .right, interactionConfiguration: interaction)
let animator = Animator(presentation: presentation)
animator.prepare(presentedViewController: viewController)

Jelly 2.0 also provides a new feature called LIVE UPDATE. Using Jellys new Live Update API it is now possible to update the alignment, size, margin-guards and corner radius when the viewcontroller is already visible.

These are the new live update functions provided by the Animator.

  • updateAlignment(alignment: PresentationAlignment, duration: Duration) - Cover & Fade
  • updateVerticalAlignment(alignment: VerticalAlignment, duration: Duration) - Cover & Fade
  • updateHorizontalAlignment(alignment: HorizontalAlignment, duration: Duration) - Cover & Fade
  • updateSize(presentationSize: PresentationSize, duration: Duration) - Cover & Fade
  • updateWidth(width: Size, duration: Duration) - Cover, Fade and horizontal Slide
  • updateHeight(height: Size, duration: Duration) - Cover, Fade and vertical Slide
  • updateMarginGuards(marginGuards: UIEdgeInsets, duration: Duration) - Cover & Fade
  • updateCorners(radius: CGFloat, corners: CACornerMask, duration: Duration) - Cover & Fade & Slide

Some of them will throw an exception if used on a not supported presentationType.
For example: It is currently not possible to update the size on a Slide-Presentation.

The presentation types can be configured with various settings:

  • size
  • margin guards
  • direction
  • horizontal & vertical alignment
  • dimmed and blurred backgroundStyle
  • duration
  • presentation and dismiss curve
  • spring damping & velocity
  • corner specification & corner radius
  • completion threshold
  • interactive drag mode (edge or pan)
  • interaction mode (present, dismiss)
  • parallax (Just available on slide Presentations)

Each component is explained in more detail in the Jelly Wiki.

Deployment target of your App is >= iOS 11.0

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

pod 'Jelly', '~> 2.2.2'

Sebastian Boldt, https://www.sebastianboldt.com

I am a mobile software architect and developer specializing in iOS. Passionate about creating awesome user experiences, designing beautiful user interfaces, and writing maintainable, structured, and best-practice orientated code. Continuously trying to improve skills and learn new technologies.

current version

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

jelly's People

Contributors

sebastianboldt avatar artemnovichkov avatar bidadh avatar danshevluk avatar plarson avatar roczhang9673 avatar

Stargazers

Rakhim Abdullayev avatar

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.