Skip to content

Sweety syntax to queue animations for the view either Async or Sync

Notifications You must be signed in to change notification settings

deda9/AnimateThen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnimateThen

Its Sweety syntax to queue animations for the view either Async or Sync

In short, it allows you to replace this:

UIView.animate(withDuration: 0.5, animations: {
            self.squareView.transform = CGAffineTransform.init(scaleX: 2.0, y: 2.0)

            UIView.animate(withDuration: 1.0, animations: {
                self.squareView.transform = CGAffineTransform.identity
                
                UIView.animate(withDuration: 2.0, animations: {
                    self.squareView.transform = CGAffineTransform.identity
                     self.squareView.alpha = 0.5
                })
                .....
            })
        })

with this sweety syntax

animate { self.squareView.transform = CGAffineTransform.init(scaleX: 2.0, y: 2.0) }
	.then { self.squareView.transform = CGAffineTransform.identity }
	.duration(1)
	.then { self.squareView.alpha = 0.5 }
	.duration(2)
	.then { self.squareView.alpha = 1 }
	.delay(0.4)
	.then { self.squareView.backgroundColor = UIColor.red }
	.duration(0.8)
	.delay(0.2)
	.completion { _ in self.squareView.backgroundColor = UIColor.green }
	.sync()

and

UIView.animate(withDuration: 0.5, animations: {
	self.squareView.transform = CGAffineTransform.init(scaleX: 2.0, y: 2.0)
 })
        
UIView.animate(withDuration: 1.0, animations: {
	self.squareView.transform = CGAffineTransform.identity
})
        
UIView.animate(withDuration: 2.0, animations: {
	self.squareView.transform = CGAffineTransform.identity
	self.squareView.alpha = 0.5
})
....

with this sweety syntax

animate { self.squareView.transform = CGAffineTransform.init(scaleX: 2.0, y: 2.0) }
	.then { self.squareView.transform = CGAffineTransform.identity }
	.duration(1)
	.then { self.squareView.alpha = 0.5 }
	.duration(2)
	.then { self.squareView.alpha = 1 }
	.delay(0.4)
	.then { self.squareView.backgroundColor = UIColor.red }
	.duration(0.8)
	.delay(0.2)
	.completion { _ in self.squareView.backgroundColor = UIColor.green }
	.async()

About

Sweety syntax to queue animations for the view either Async or Sync

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages