Git Product home page Git Product logo

motion's Introduction

Motion Logo

Motion

Welcome to Motion, a library used to create beautiful animations and transitions for views, layers, and view controllers.

Photos Sample

Take a look at a sample Photos project to get started.

Photos

Who is Motion for?

Motion is designed for beginner to expert developers. For beginners, you will be exposed to very powerful APIs that would take time and experience to develop on your own, and experts will appreciate the time saved by using Motion.

What you will learn

You will learn how to use Motion with a general introduction to fundamental concepts and easy to use code snippets.

Transitions

Motion transitions a source view to a destination view using a linking identifier property named motionIdentifier.

Match Translate Rotate Arc Scale
Match Translate Rotate Arc Scale

Example Usage

An example of transitioning from one view controller to another with transitions:

View Controller 1

greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"

View Controller 2

isMotionEnabled = true
greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"
orangeView.transition(.translate(x: -100))

The above code snippet tells the source views in view controller 1 to link to the destination views in view controller 2 using the motionIdentifier. Animations may be added to views during a transition using the transition method. The transition method accepts MotionTransition structs that configure the view's animation.

UINavigationController, UITabBarController, and UIViewController Transitions

Motion offers default transitions that may be used by UINavigationControllers, UITabBarControllers, and presenting UIViewControllers.

Push Slide ZoomSlide Cover Page Fade Zoom
Push Slide Zoom Slide Cover Page Fade Zoom

Example Usage

An example of transitioning from one view controller to another using a UINavigationController with a zoom transition:

UINavigationController

class AppNavigationController: UINavigationController {
    open override func viewDidLoad() {
        super.viewDidLoad()
        isMotionEnabled = true
        motionNavigationTransitionType = .zoom
    }
}

To add an automatic reverse transition, use autoReverse.

motionNavigationTransitionType = .autoReverse(presenting: .zoom)

Animations

Motion provides the building blocks necessary to create stunning animations without much effort. Motion's animation API will make maintenance a breeze and changes even easier. To create an animation, use the animate method of a view or layer and pass in a list of MotionAnimation structs. MotionAnimation structs are configurable values that describe how to animate a property or group of properties.

Background Color Corner Radius Fade Rotate Size Spring
Background Color Corner Radius Fade Rotate Size Spring
Border Color & Border Width Depth Position Scale Spin Translate
Border Color & Border Width Depth Position Scale Spin Translate

Example Usage

let box = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
box.backgroundColor = .blue

box.animate(.background(color: .red), .rotate(180), .delay(1))

In the above code example, a box view is created with a width of 100, height of 100, and an initial background color of blue. Following the general creation of the view, the Motion animate method is passed MotionAnimation structs that tell the view to animate to a red background color and rotate 180 degrees after a delay of 1 second. That's pretty much the general idea of creating animations.

Requirements

  • iOS 8.0+
  • Xcode 8.0+

Communication

  • If you need help, use Stack Overflow. (Tag 'cosmicmind')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, and can provide steps to reliably reproduce it, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Embedded frameworks require a minimum deployment target of iOS 8.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Motion's core features into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Motion', '~> 3.1.0'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Motion into your Xcode project using Carthage, specify it in your Cartfile:

github "CosmicMind/Motion"

Run carthage update to build the framework and drag the built Motion.framework into your Xcode project.

Change Log

Motion is a growing project and will encounter changes throughout its development. It is recommended that the Change Log be reviewed prior to updating versions.

License

The MIT License (MIT)

Copyright (C) 2019, CosmicMind, Inc. http://cosmicmind.com. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

motion's People

Contributors

confusedvorlon avatar danieldahan avatar jeehut avatar orkhanalikhanov 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  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

motion's Issues

Transition view overlaying other views with .zPosition applied

I have a background view with the following applied to it inside the home controller:
bkgd.isMotionEnabled = true bkgd.motionIdentifier = "bkgd" bkgd.transition([.spring(stiffness: 300, damping: 25), .duration(0.3), .beginWith(modifiers:[.zPosition(0)]), .useGlobalCoordinateSpace])

And inside the transition to controller I have:
bkgd.isMotionEnabled = true bkgd.motionIdentifier = "bkgd" bkgd.transition([.spring(stiffness: 300, damping: 25), .duration(0.3), .beginWith(modifiers:[.zPosition(0)]), .useGlobalCoordinateSpace])

The motion transition type is: motionTransitionType = .autoReverse(presenting: .slide(direction: .right)) and I'm using the standard self.present(vc, animated: true) to initiate the transition.

The problem: When transition the background comes to the front of the view obscuring all other elements until the transition has finished. At this point it returns to it's respective zPosition. I am using xib's instead of storyboards.

Transition Animations

`
import UIKit
import Material

class ConfirmVC: UIViewController {

  override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    
}
override func viewDidLoad() {
    isMotionEnabled = true
     motionModalTransitionType = .autoReverse(presenting: .zoom)
    super.viewDidLoad()
}.....`

motionModalTransitionType this is not found , with importing Material , Motion , or both

Update to Swift 4.2

Update to Swift 4.2.
The conversion with Xcode 10 is automatic, and we'll be very happy.

Thanks!

control interactive transition

Hello! How can I control an interactive transition? In Hero we can do this like:

`

@objc func pan(gr: UIPanGestureRecognizer) {

    let translation = gr.translation(in: self)

    switch gr.state {
    case .began:
        parentViewController?.dismiss(animated: true, completion: nil)
    case .changed:
        Hero.shared.update(translation.y / bounds.height)
    default:
        let velocity = gr.velocity(in: self)
        if ((translation.y + velocity.y) / bounds.height) > 0.5 {
            Hero.shared.finish()
        } else {
            Hero.shared.cancel()
        }
    }
}

`

But in Motion we have the following lines, that commented:
`
/**

The singleton class/object for controlling interactive transitions.

Motion.shared

Use the following methods for controlling the interactive transition:

func update(progress: Double)
func end()
func cancel()
func apply(transitions: [MotionTargetState], to view: UIView)

*/
`

May be there is another way to do this?

IMPORTANT SWIFT SETTINGS

I was running into multiple errors like below:

.../Pods/Material/Sources/iOS/Font.swift:97:59: Cannot force unwrap value of non-optional type 'CGFont' .../Pods/Material/Sources/iOS/Material+NSMutableAttributedString.swift:40:39: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/Material+NSMutableAttributedString.swift:50:42: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/Material+NSMutableAttributedString.swift:61:42: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/Material+UIFont.swift:44:18: Type 'String' has no member 'font' .../Pods/Swift.String:231:16: Did you mean 'count'? .../Pods/Material/Sources/iOS/NavigationItem.swift:44:27: Cannot convert value of type 'Button' to specified type 'IconButton' .../Pods/Material/Sources/iOS/SearchBar.swift:112:83: Type 'String' has no member 'foregroundColor' .../Pods/Material/Sources/iOS/SearchBar.swift:122:83: Type 'String' has no member 'foregroundColor' .../Pods/Material/Sources/iOS/TextStorage.swift:108:93: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/TextStorage.swift:129:45: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/TextStorage.swift:141:45: Use of undeclared type 'NSAttributedStringKey' .../Pods/Material/Sources/iOS/TextStorage.swift:152:48: Use of undeclared type 'NSAttributedStringKey'

The resolutions for this is to change the pods setting to use Swift 4.0. You can do this by selecting your Pods project in the project browser in XCode and then select the 'Material' pod/framework from the list of pods/frameworks on the left.

image

Can I create custom transition?

Can I create custom transition? Here is my interaction.

VC_1 (fromView)
 - topViewA
 - contentViewA
 - buttonA
 - bottomViewA

VC_2 (toView)
 - buttonB
 - topViewB
 - contentViewB

bottomViewA of VC_1 and topViewB of VC_2 is same view.
When VC_1 present VC_2, VC_1 and VC_2 is overwrapped with bottomViewA and then VC_1 is translated by y. It looks like scrolling effects.

So view layer looks like during transition

- topViewA
- contentViewA
- buttonA
- buttonB
- bottomViewA = topViewB
- contentViewB

Here is my code

toViewSnapshot.frame = CGRect(x: 0, y: bottomViewA.y, width: width, height: height)
fromViewSnapshot.addSubview(toViewSnapshot)

    UIView.animate(withDuration: 10, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
      snapshotFromView.frame = CGRect(x: 0, y: -bottomViewA.y, width: toView.frame.width, height: toView.frame.height)
    }, completion: { _ in
      self.snapshotViews.values.forEach { $0.removeFromSuperview() }
      self.snapshotViews.removeAll()
      transitionContext.completeTransition(true)
    })

If I added fromViewSnapshot and toViewSnapshot to containerView, I cannot create view hierarchy that I want (animating views are added toViewSnapshot or fromViewSnapshot)

After some search for a good solution, I found your project. This is awesome!
Could you give some advise if I use Motion?

Is there a way to know when the animation is complete?

I am using the motion library very usefully.

However, I would like to have an event to know the end of motion.
We are currently using a function called delayedCall, but it would be nice to know this as an event.

Are you willing to support this?

Thank you for providing a good library.

White flash when pushing/popping a view controller

I want to push/pop a view controller with just a fade-in fade-out transition between them. I couldn't achieved it, instead I see the screen is flashing white in the middle of the transition. Please check out the GIF provided below for clarification.

Is there a way to have just a fade transition when pushing/popping view controllers?

motion_flash_issue

Does the ability to apply animations immediately exist?

I expected the transform to be applied when I applied .duration (0.0) in the motion (...) function, but it did not.

The animation application I want is as follows.

Cell.transform = CGAffineTransform (scaleX: 0, y: 0)
Cell.motion ([. Scale (1), .duration (defaultTimeInterval), .timingFunction (.easeOut)])

I applied the first line to cell.motion (.scale (0), .duration (0)), but internally it seems that the default of duration applies.

If .duration (0), can the transform be applied immediately?

I always appreciate quick answers.

Objective-C methods not available

When trying to set an identifier in Obj-C the option to set the motionIdentifier does not exist. I have tried with setMotionIdentifier and with self.label.motionIdentifier.

Am I missing something?

Can I use different MotionTransitionType in one UIViewcontroller

Say I have a UIViewController UV1 which is embedded in an AppNavigationController and Another two UIViewController UV2 and UV3. I want to push UV2 or UV3 from UV1.

class AppNavigationController: NavigationController {
  open override func prepare() {
    super.prepare()
    isMotionEnabled = true
    motionNavigationTransitionType = .autoReverse(presenting: .zoom)
  }
}

The problem is both transitions for UV2 and UV3 is "zoom".
If I want the transition for UV2 is zoom, but the one for UV3 is "slide", what should I do to achieve it?
Thanks!

Weak Should Not Be Applied In A Protocol

Pods/Motion/Sources/Preprocessors/MotionPreprocessor.swift:33:5

'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions

weak var motion: MotionTransition! { get set }

View blinks when popping view controller on UINavigationController

First of all, sorry for my bad English.

I'm using Motion on my project in UINavigationController, view blinks with black color when pushing/pop view controller repeatedly after 10 times.

First 10 times of translation is OK and no glitches, but it blinks weirdly by repeating popping vieewcontroller a few times after.
Additional: And some subview blinks when pushing view controller after pushing 10 times.

I just enabled isMotionEnabled property on my UINavController and UIViewController.
Here is my view controller code for setup Motion:

self.isMotionEnabled = true
self.navigationController?.motionNavigationTransitionType = .autoReverse(presenting: .fade)
current.motionIdentifier = "ppj-header-progress"

I tried to remove motionNavigationTransitionType but same result.

Update: This issuse is caused on iPhone X, iOS 11.1.1
Update 2: My code works perfectly and not happening any issue on iPhone 4s, iOS 9
Update 3: Not happening black blink issue on iPhone 5s, iOS 11 but some subviews translates weirdly (e.g. blinking layer shadows) when pushing/popping view.

ezgif com-optimize

Animation compile error of .delay

When I tried to code like following as the official documents said
animate([.rotate(270), .fadeOut, .scale(0.01), .delay(1)]){ [weak self] in
}
Xcode gave me "Extra argument in call" compile error.
When I removed .delay(1), everything works fine again.

I also found I can not use .duration(1) like that neither.

transparent background navigationcontroller

HI,

I have a strange problem. If I make transition by navigation controller from 1 to 2 view controller and 2nd viewcontroller has a transparent background so it get for some ms black. but it is possible to observe. Do you know how to solve it?

Thanks.

Slow animations when using present()

I'm trying to simulate a button down -> button up animation before presenting the view controller and there's a noticeable delay before the present animation is called. I'm using UIView.animate and that is performing the animation smoothly. When it comes to present the controller using there's a delay of a couple of ms before it initiates. I've tried various workarounds to solve this including the code below and it might be related to Motion "Crunching the numbers". Are there any ways to solve this?

                           `DispatchQueue.main.async {
			
			let vc = CourseViewController(nibName: CourseViewController.identifier, bundle: nil)
			vc.course = courses[indexPath.row]
			vc.cellValue = indexPath.row
			vc.view.motionIdentifier = "Course-\(indexPath.row)"
			vc.view.transition([.spring(stiffness: 300, damping: 25), .duration(0.1), .useScaleBasedSizeChange, .forceAnimate, .fadeIn, .corner(radius: 16), .masksToBounds(true)])
			
			self.courseCollection.transition([.beginWith(modifiers:[.zPosition(10)]), .useGlobalCoordinateSpace, .forceAnimate, .fade(0.0), .duration(0.1), .spring(stiffness: 300, damping: 25)])
			
			UIView.animate(withDuration: 0.2, delay: 0.0, options: [.allowUserInteraction, .curveEaseIn], animations: {
				cell.boxView.transform = CGAffineTransform(scaleX: 0.95, y: 0.95)
			}, completion: { _ in
				
				UIView.animate(withDuration: 0.3, delay: 0.0, options: [.allowUserInteraction, .curveEaseOut], animations: {
					cell.boxView.transform = CGAffineTransform.identity
					
				}, completion: { _ in
                                              // Slow point here
					self.present(vc, animated: true)
				})
			})
			
		}`  

About extension CALayer: CAAnimationDelegate {}

I found the following code in Motion+CALayer.swift
@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {}

The problem is now I want to make my own customize CALayer which conforms CAAnimationDelegate. But because of the "extension CALayer: CAAnimationDelegate {}", it seems I can not do it.

Can you help me to work it out? Thank you.

Unbalanced calls to begin/end appearance

I got this message when presenting this Navigationcontroller.
"Unbalanced calls to begin/end appearance"
(The animation works as expected)

class AnimatableNavController: UINavigationController {

    var transtype:MotionTransitionAnimationType?
    
    open override func viewDidLoad() {
        super.viewDidLoad()
        isMotionEnabled = true
        motionTransitionType = transtype ?? .push(direction: .right)
        motionNavigationTransitionType = transtype ?? .push(direction: .right)
    }
}

Animate back to original state

Hello. I'm using Motion to achieve a rotation effect on a button. This is what I'm doing :

if isAdding {
    // Close adding, resetting all stuff
    btnAdd?.animate(MotionAnimation.rotate(45))
    isAdding = false
} else {
    // Open adding
    btnAdd?.animate(MotionAnimation.rotate(-45))
    isAdding = true
}

When I need to rotate back the button, I'm not able to achieve the "back" animation. How can I do? It seems the button starts always from the original position.

motion intro

this would be part of the identity of cosmic mind

Update to Swift 4.2

The development branch seems to be updated to swift 4.2 but .podspec file should also have swift_version = '4.2'

Current .podspec:

Motion/Motion.podspec

Lines 2 to 4 in 0132613

s.name = 'Motion'
s.version = '1.5.0'
s.swift_version = '4.0'

Adding Motion as pod interferes with UIImagePickerController

Motion looks like an awesome library! Playing around with it now, and noticed something.

When adding the pod the delegates of UIImagePickerControllerDelegate is not called:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any])

and

func imagePickerControllerDidCancel(_ picker: UIImagePickerController)

When removing Motion from the Podfile, the delegates work.

Views alpha reseting to 1 after view disappear.

Im using a TabBarController with fadeIn and fadeOut transition modes.
My issue is that some subviews of one of the presenting view controllers are setting the alpha back to 1 after I animated them with fadeOut before exiting the view controller.
It sounds like a problem with the fade transitions used between view controllers and views being animated as well.

Update: Problem persist after removing the subview fade animation. Seems to be completely related to the transition mode.

Using version 1.1.2 of cocoapods.

Properties conflict with Apple's CoreMotion

Some properties seem conflict with CoreMotion such as isMotionEnabled, motionIdentifier.
It shows

Ambiguous use of 'isMotionEnabled'
Ambiguous use of 'motionIdentifier'
Ambiguous reference to member 'animate'

The problem happened on Xcode8.3, Swift3.
screen shot 2017-07-25 at 2 32 20 pm

RightBarButtonItem is unclickable when using Xcode 9 + ios 10

When I use code as following, the rightBarButtonItem becomes unclickable (XCode 9 + ios 10),
But ios 11 is totally OK. When I changed back to normal UINavigationController, everything is OK again. Would you like to check this problem since there are many people who are still using ios 10.
Thanks a lot!

class AppNavigationController: NavigationController {
  open override func prepare() {
    super.prepare()
    isMotionEnabled = true
    motionNavigationTransitionType = .autoReverse(presenting: .zoom)
  }
}

how to animate multiple uiview objects

is there a way to animate multiple attributes of multiple uview objects using same motion duration delay etc.??? or in other words equivalent to UIView.animate
or
Motion.animate(duration: 0.3, animations: { view.translate(x: 0, y: 100) view2.rotate(50) })

Shadow clipping when transitioning

Currently trying have a shadow on a UIView within a UITableViewCell and when performing the transition the cell shadow clips until the end animation state. I have all the normal properties set to false (clipsToBounds etc). First approach was to attach the shadow to the UIView layer and that worked until Motion was introduced to the UITableView:

boxView?.layer.shadowColor = Theme.Colors.shadow!.cgColor boxView?.layer.shadowOpacity = 0.8 boxView?.layer.shadowRadius = 20 boxView?.layer.shadowOffset = CGSize(width: 0, height: 5) boxView?.layer.shadowPath = UIBezierPath(roundedRect: boxView.bounds, cornerRadius:20).cgPath

Second approach is what I'm currently trying and that is to attach the shadow to the transition of the cell:

cell.boxView.isMotionEnabled = true cell.boxView.isMotionEnabledForSubviews = true cell.boxView.motionIdentifier = "box-\(indexPath.row)" cell.boxView.transition([ .shadow(offset: CGSize(width: 0, height: 10)), .shadow(radius: 16), .shadow(color: Theme.Colors.green!), .shadow(opacity: 1), .shadow(path: UIBezierPath(roundedRect: cell.boxView.bounds, cornerRadius: 20).cgPath), .masksToBounds(false), .durationMatchLongest, .forceAnimate, .useGlobalCoordinateSpace, .useScaleBasedSizeChange ]) cell.layoutIfNeeded()

Either approach fails to work and results in the cell shadow being clipped until the end of the animation motion provides.

The UITableView has the following MotionIdentifiers attached to it:

basicTableView.transition([.beginWith(modifiers:[.zPosition(5)]), .useGlobalCoordinateSpace, .fade(0.0), .duration(0.25), .spring(stiffness: 300, damping: 25), .translate(x: -300), .masksToBounds(false)])

Thanks

Issue with flickering on transitioning from VC

Getting a huge flickering

I'm currently trying to transition from one VC1 to VC2 when a user clicks a cell. The transitions and their have been set to be the boxView cell of a collection view within VC1 to the background view of VC2. When I transition over to VC2 and back half of VC2 is missing from the transition. There's also an issue when I dismiss VC2 the boxView of VC1 collection view cell is 1/4 the size that it should be and shifted along the X axis.

VC1 didSelectCell code:

                    `if let cell = collectionView.cellForItem(at: indexPath) as? CourseCell {
		
		let cardData = "cell-\(indexPath.row)"
		cell.boxView.transition([.useNoSnapshot, .spring(stiffness: 250, damping: 25)])
		cell.boxView.motionIdentifier = cardData
		
		let vc = CourseViewController(nibName: CourseViewController.identifier, bundle: nil)
		vc.course = courses[indexPath.row]
		vc.isMotionEnabled = true
		vc.motionTransitionType = .none
		
		vc.view.motionIdentifier = cardData
		vc.view.transition([.source(cardData), .useNoSnapshot, .spring(stiffness: 250, damping: 25)])
		vc.lessonsTableView.motionIdentifier = "course-\(indexPath.row)"
		
		UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseIn, animations: {
			cell.boxView.transform = CGAffineTransform.init(scaleX: 0.95, y: 0.95)
		}) { _ in
			self.present(vc, animated: true)
			cell.boxView.transform = .identity
		}
	}`

VC1 cellForRowAt code:

            `cell.motionIdentifier = "cell-\(indexPath.row)"
	cell.boxView.motionIdentifier = "course-\(indexPath.row)"
	cell.transition([.fadeIn, .scale(1)])`

I've spent the passed couple of days trying to solve this and no luck.

Stop and remove all animations

Hello!
How can I remove all animations from my view?
I've tried to do
myView.layer.removeAllAnimations()
But seems it doesn't work properly. I've found method removeAllMotionAnimations in your extension for CALayer, but it is marked as internal.

Transition Animations

Hi, I don't get how to use TransitionAnimations , in the example bellow the gifs I change my VC class to UINavigationController but cant find the variable motionTransitionType (or something like that ) , and in the examples codes you just used default swift UIViewController and cant find such these methods or Variables to set to .zoom or what .. , can you explain how to use these animations ??

Animate view that is not paired to previous view controller

Hello!

How can a view that doesn't have a motionIdentifier or simply doesn't match any identifier from the previous view controller to be animated at the same time the presentation animation happens?

I tried to add animations to this view using motionAnimations but they seem that are not executed.

I additionally tried to use view.motion(...) to animate this view in viewWillAppear but if I don''t use delay I cannot see the animations. I achieved what you can see in next gif adding a delay to the animations of this view after view controller is pushed and before it's popped. As you can notice the white view with the game's description appears after the transition has finished.

motion_animation_issue

Example code:

    /********* Pushed view controller's code *********/
    override func viewDidLoad() {
        super.viewDidLoad()
        // Set initial state for animatable views
        backgroundImage.motion(.duration(0.0), .translateX(-view.frame.width))
        tableView.motion(.duration(0.0), .translateY(view.frame.height))
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        let duration = 0.3
        let delay = 0.3
        let timing = MotionAnimation.timingFunction(.easeInEaseOut)

        backgroundImage.motion(.delay(delay), .duration(duration), .translateX(0), timing)
        tableView.motion(.delay(delay), .duration(duration), .translateY(0), timing)
    }

    @IBAction func backButtonDidTouch(_ sender: Any) {
        let duration = 0.3
        let timing = MotionAnimation.timingFunction(.easeInEaseOut)

        backgroundImage.motion([.duration(duration), .translateX(-view.frame.width), timing])
        tableView.motion([.duration(duration), .translateY(view.frame.height), timing])

        DispatchQueue.main.asyncAfter(deadline: .now() + duration) { [unowned self] in
            _ = self.navigationController?.popViewController(animated: true)
        }
    }

issue with interactive transition

Hello!
Brach: Development.
Version: 2.0.0
Issue: I have a UINavigationController with some viewControllers. And I have a PhotoController which will dismiss interactively.
PhotoController has modalPresentationStyle = .custom.
Simple code for interactive dismiss:

func pan() {
        let translation = panGR.translation(in: nil)
        let progress = abs(translation.y / 2 / collectionView!.bounds.height)
        switch panGR.state {
        case .began:
            motionDismissViewController()
        case .changed:
            MotionTransition.shared.update(TimeInterval(progress))
            if let cell = collectionView?.visibleCells[0]  as? ScrollingImageCell {
                let currentPos = CGPoint(x: translation.x + view.center.x, y: translation.y + view.center.y)
                MotionTransition.shared.apply(modifiers: [.position(currentPos)], to: cell.imageView)
            }
        default:
            if progress + abs(panGR.velocity(in: nil).y) / collectionView!.bounds.height > 0.3 {
                MotionTransition.shared.finish()
            } else {
                MotionTransition.shared.cancel()
            }
        }
    }

The issue is if MotionTransition.shared.cancel() is called, then viewWillDisappear will be called on the previous controller and after that viewWillDisappear and viewWillAppear won't be called on every controllers in the UINavigationController (which was under PhotoController).

If comment these lines in MotionTransition.swift :
telegram-cloud-file-2-257907020-90574-3821470602619572564
then all is fine.

Could you please check. Thanks

Jitter at animation end

I've just updated our code to utilise the new Motion framework instead of the old one built in to Material.

Using the Motion.rotation(angle:) function on a FabButton (as primary button of a Material Menu) works fine in terms of animating the button. However, we're noticing a flash of the initial animation state at the end of the rotation (GIF recording)

menu.views.first?.animate(animation: Motion.rotation(angle: -90))

Any ideas what might cause this?

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.