Code Monkey home page Code Monkey logo

lazytransitions's Introduction

LazyTransitions

Platform: iOS 8+ Language: Swift 3 Cocoapods Carthage Compatible License: BSD Twitter: serp1412

A simple framework that allows you to create similar lazy pops and dismisses like in the Facebook, Instagram or Twitter apps.

LazyTransitions

Installation

CocoaPods

Add the following line to your PodFile:

pod 'LazyTransitions'

Carthage

Add the following line to your Cartfile

github "serp1412/LazyTransitions"

Usage

Here's the simplest way to use LazyTransitions

  • Import the framework in the view controller that you want to make lazy
import LazyTransitions
  • Make the view controller lazy for the transition that you need
func viewDidLoad() {
    becomeLazy(for: .dismiss) // or .pop if have pushed this screen
}
  • A lazy transition trigger is automatically added to the screen's view property. But you can add transition triggers (i.e. panning on them will also trigger a transition) for other views in your screen
addTransition(forView: view)
// or
addTransition(forScrollView: scrollView)

Example

Here's some sample code on how to use LazyTransitions in your project.

import LazyTransitions

class LazyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        becomeLazy(for: .dismiss)
    }
}

That's it! ๐Ÿ˜œ

More Info Please!

If you want to find out about more use cases for LazyTransitions or just mess around with it a bit.

  1. Clone this project
  2. Open it in Xcode and find the LazyTransitions.playground file
  3. Open the README playground page and follow the instructions inside.

I hope you enjoy using this framework as much as I did creating it ๐Ÿ˜Š

lazytransitions's People

Contributors

s2dentik avatar sergheic avatar serp1412 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lazytransitions's Issues

Custom Presentation Controller

Hi there,

This library is really neat, I'm enjoying trying it out, but running into an issue that I can't seem to think of a way around. I'm attempting to achieve an effect like this. I'm trying to make LazyTransitioner and a UIPresentationController work nicely together to achieve an effect like this.

Semi-modal

I tried following the README's advice of doing this instead of forward the animator and interactor properties, but it's not working because of the situation below.

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    // ... pass the animator
    return transitioner.animator
}
    
func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
    // ... pass the interactor
    return transitioner.interactor
}

But the problem is that I still need my own implementation of func animationController(forDismissed dismissed: UIViewController) to properly dismiss.

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return MyCustomTransition(isReversed: true, duration: 0.4)
}

My suggestion would be to be able to pass in a custom UIPresentationController which can be used in conjunction with the transitioner, though I'm a bit fuzzy on the implementation.

I would love to figure out if this is currently possible, and if not, find out if it's possible to add in the future.

Thanks a lot!

UI flickering issue

Hello,

I have tried with this code, it is really nice but facing one problem. The UI flickers when swipe to dismiss.

Same happening while tapping on button "Dismiss Demo" and try to swipe left to right to dismiss. The view sometime flickers.

Not sure where it goes wrong, Was checking how other library does it smooth like https://github.com/lkzhao/Hero

But not able to find better solution for it, I have found something in their code but not sure how it is working, here is the screenshot.

File: HeroTransition+Start.swift
screen shot 2017-11-08 at 2 24 27 pm

Please let me know if required more info.

Thanks
Hiren

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.