marcosgriselli / viewanimator Goto Github PK
View Code? Open in Web Editor NEWViewAnimator brings your UI to life with just one line
License: MIT License
ViewAnimator brings your UI to life with just one line
License: MIT License
Don't know
Working in Swift
hello, can u help noob to make animation like this https://dump.video/i/Upf9UB.mp4
(when all elements bounce a little )
I have a button that uses an AnimationType(.bottom, offset: 10)
animation whenever it is tapped.
The button should perform the animation and return to its original position.
The button performs the animation but changes it's y position with every tap. For example, here is the CGRect of the button for each button animation:
(247.6666666666667, 10.0, 106.33333333333334, 30.0)
(247.6666666666667, 20.0, 106.33333333333334, 30.0)
(247.6666666666667, 30.0, 106.33333333333334, 30.0)
(247.6666666666667, 40.0, 106.33333333333334, 30.0)
UIView.animate(views: [button], animations: [buttonAnimation], reversed: true, initialAlpha: 1.0, finalAlpha: 0.0, completion: {print(self.button.frame)})
Hello! Thanks for the wonderful framework! I ran into the problem that UICollectionView cells appear before the animation starts, at this point the cells are loading photos and the user names are already visible. Please tell me how can this be avoided?
self?.collectionView.refreshControl?.endRefreshing()
let offset = UIScreen.main.bounds.width
let fromAnimation = AnimationType.from(direction: .left, offset: offset)
let animationInterval = 0.1
self?.collectionView.animateViews(animations: [fromAnimation], initialAlpha: 1, finalAlpha: 1, delay: 0, duration: 0.4, animationInterval: animationInterval, completion: {
})
self?.collectionView.reloadData()
🙊
Hello Marcos, Im facing a problem when I try to run your example:
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
I tried to convert but it didn't worked.
Im on Xcode 8.3 tried swift v3 and v4
Can you help me?
Thanks
Carlos
Wish there was a swiftui support, cuz this'd be so much faster
Please consider! ❤️
Thats all)
pod "ViewAnimator" is not installing on existing project.Though it is installing on newly created project.
Hi! The animation is not working, i am using a XIB, i would like to know if there is a fix to this features
Thanks in advance!
On iOS 10 we were introduced to UIViewPropertyAnimator
which comes packed with amazing features to create rich and interactive animations. ViewAnimator relies on the old UIView
animations API in order to support previous versions of iOS, but we could extend for iOS 10+ using UIViewPropertyAnimator specific functionalities (like reversing animations or changing it's completion percentage manually).
I tried using it and the only exposed method for a view is "animateRandomWithInterval"
Thanks
looking for better example hide and show animation of view inside stackView
How can I set animation for particular section of table view??
👆
I think, implementation restoreViewsToIdentity()
on reverse should be by default. Are there any cases to use hidden view after reversed animation below its necessary position?
The current example app is a really simple approach on what can be done with ViewAnimator. Even though the library is not complex to integrate and use on your own projects it would be nice to show how to use different animations in different scenarios.
I'd be replicating the app should on the animations Complex header.
hi, thanks for your awesome framework.
Is there any way to animateViews
of collectionView for a set of indexPath ie. Array of IndexPath.
I have pagination on my collection view and every time I append items on it the whole collection view starts animating ( which I don't want).
I just wanted to animate for a selected array of index paths.
Cheers.
Hi,
Would it be possible to support timing functions like https://github.com/cats-oss/Sica#easingfunctions in ViewAnimator?
Thanks for this library.
When the collection view is loaded for the first time, the animation does not work.
sender.isEnabled = false
activityIndicator.stopAnimating()
items = Array(repeating: nil, count: 20)
self.collectionView!.reloadData()
self.collectionView!.animateViews(animations: [AnimationType.from(direction: .right, offset: 30.0)],
completion: {
sender.isEnabled = true
})
Getting the following error when trying to archive.
ERROR ITMS-90056: "This bundle Frameworks/ViewAnimator.framework is invalid.
The Info.plist file is missing the required key: CFBundleVersion.
Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
Using Carthage:
github "marcosgriselli/ViewAnimator"
Aninate and not crash. This was working a month ago. I just reopened my project and now I can't get it working
Crash in line 49 of ViewAnimator.swift
tableView.animateViews(animations: [AnimationType.from(direction: .bottom, offset: 30.0)])
How can I use an animate a UITableView
's cells on viewDidLoad()
?
Hey
The issue happens right here, in my case dispatchGroup.leave()
happens more times then dispatchGroup.enter()
which causes EXC_BREAKPOINT
Probably, subviews count changes during asyncAfter
The code, invoked the animation is this:
let fromAnimation = AnimationType.from(direction: .right, offset: 400.0)
animateViews(animations: [fromAnimation], initialAlpha: 0.0, finalAlpha: 1.0, delay: 0.0, duration: 0.2, animationInterval: 0.2, completion: nil)
Cheers
Install through pod install
[!] Unable to find a specification for ViewAnimator
[!] Unable to find a specification for ViewAnimator (~> 1.0)
[!] Unable to find a specification for ViewAnimator (~> 1.0.2)
import ViewAnimator
let moveFromLeftAnimation = AnimationType.from(direction: .left, offset: 50)
swipeTextLabelOutlet.animate(animations: [moveFromLeftAnimation], initialAlpha: 0, finalAlpha: 1, delay: baseDelay + delayTwo, duration: duration)
results in
Cannot infer contextual base in reference to member 'left'
Type 'AnimationType' has no member 'from'
Possible choices are
#70 introduced a new animation case called .vector(CGVector)
which replaced the old .from(Direction, CGFloat)
case. This new type has a bug where the animations are performed in an incorrect direction.
view.animate(animations: AnimationType.vector(CGVector(dx: 0, dy: 30)))
Should translate the view from top to bottom by 30 points but it's happening in a reversed order.
if view has a tranform before animation,the tranform will become CGAffineTransform.identity when animation finish
import Foundation
import UIKit
/// Animations completion block
public typealias CompletionBlock = (()->())
private var kViewAnimationPreTransformKey = "kViewAnimationPreTransformKey"
// MARK: - UIView extension with animations.
public extension UIView {
var preTransform: CGAffineTransform? {
get {
return objc_getAssociatedObject(self, &kViewAnimationPreTransformKey) as? CGAffineTransform
}
set {
objc_setAssociatedObject(self, &kViewAnimationPreTransformKey, newValue, .OBJC_ASSOCIATION_RETAIN)
}
}
/// Performs the animation.
///
/// - Parameters:
/// - animations: Array of Animations to perform on the animation block.
/// - initialAlpha: Initial alpha of the view prior to the animation.
/// - finalAlpha: View's alpha after the animation.
/// - delay: Time Delay before the animation.
/// - duration: TimeInterval the animation takes to complete.
/// - completion: CompletionBlock after the animation finishes.
public func animate(animations: [Animation],
initialAlpha: CGFloat = 0.0,
finalAlpha: CGFloat = 1.0,
delay: Double = 0,
duration: TimeInterval = ViewAnimatorConfig.duration,
completion: CompletionBlock? = nil) {
// Apply initial transform and alpha
animations.forEach {
preTransform = transform
transform = transform.concatenating($0.initialTransform)
}
alpha = initialAlpha
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
UIView.animate(withDuration: duration, animations: { [weak self] in
self?.transform = self?.preTransform ?? CGAffineTransform.identity
self?.alpha = finalAlpha
}, completion: { _ in
completion?()
})
}
}
}
Instead of
private func indexPathFor(cell: UICollectionViewCell) -> Int {
return indexPath(for: cell)?.item ?? -1
}
public var views: [UIView] {
let items = visibleCells
return items.sorted(by: { indexPathFor(cell: $1) > indexPathFor(cell: $0) })
}
better to use:
public var views: [UIView] {
return indexPathsForVisibleItems.sorted().compactMap { cellForItem(at: $0) }
}
Hi! I'm pretty new in swift and I didn't exactly understood where to call the animation in an UITableView..
I want to reproduce something like this
I've tried calling it inside viewDidLoad
but nothing happens, the same in viewWill/DidAppear
..
That's my code:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hero.isEnabled = false
self.navigationController?.hero.isEnabled = false
tableView.reloadData()
let cells = tableView.visibleCells(in: 0)
let animation = AnimationType.from(direction: .bottom, offset: 30.0)
UIView.animate(views: cells, animations: [animation])
}
Is there any way to define, at this time, a repeat interval for a given animation?
Hi Marcos, I love these transitions and would like to incorporate them on my new project. I'm having trouble using it to transition between two view controllers. Is it possible to do that with ViewAnimator or is it only for loading a view within a view controller?
Here is the way I'm doing my transition between the two view controllers right now:
// In VC1 call this func to transition to VC2
func goToVC2() {
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let VC2 = storyBoard.instantiateViewController(withIdentifier: "VC2") as! VC2
self.present(VC2, animated: true, completion: nil)
}
Animation should work in every VC
Animation only works in initial VC
Creating two VCs, connecting them, using a code like
let fromAnimation = AnimationType.from(direction: .left, offset: 80)
headingTextLabel.animate(animations: [fromAnimation], delay: 0, duration: 0.5)
mainTextView.animate(animations: [fromAnimation], delay: 0, duration: 0.5)
continueButton.animate(animations: [fromAnimation], delay: 0.2, duration: 0.5)
and see the animation only on the initial VC
There should be a parameter for reversed animation
No method found. Seems to be removed from last versions
Make a simple project, try to find the following method of tableView example
tableView.animateViews(animations: [animation], reversed: true, initialAlpha: 1.0, finalAlpha: 0.0,
completion: {
self.tableView.restoreViewsToIdentity()
self.tableView.reloadData()
self.activityIndicator.startAnimating()
})
No method found with current version
Swift 4, iOS 11, 1.0.4 version of ViewAnimator
when setting usingSpringWithDamping
and initialSpringVelocity
it seems as if they have no effect; no spring animation at all... Am I missing something?
E.g. the zoom animation is linear, the view grows - but now springin
usingSpringWithDamping
to e.g. 3, 0.3, ...initialSpringVelocity
to e.g. 5, 0.5, ...UIView.animate
EarlGrey is an iOS UI Automation Test framework created by Google.
One of the main features we could use to create UITests on ViewAnimator is the Synchronization feature for animations and Visibility Checks for determining the visibility of certain UI. This is exactly what we need to create tests.
I feel this is a better alternative for this particular case than XCUI.
Hello! There was a problem when using ViewAnimator
and UIRefreshControl
, that is, if for the first time the animation works as it should, then the second time after the data is reloaded with UIRefreshControl
, the bottom three cells appear without animation. Of course, I understand that this is due to the fact that these cells are not visibleCells (at the start of the animation, 12 cells are visible, after the animation 15), but how to solve this problem?
Please see the video https://monosnap.com/file/CNs9V8EKIWbOsuLzXcybqfMRDb5jYp
Update: At the moment I made a hack that I increase the CollectionView
height to a value that helps to animate the lower row of cells, but there may be options to do it better.
Is there any way to extend AnimationType
to add custom animations using CGAffineTransforms
?
There does not seem any documentation on this
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.