Skip to content

super-ultra/ScrollMechanics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scroll Mechanics

This is an example of a simple scroll view mechanics implementation.

Important

I use single animation for contentOffset to simplify the example:

contentOffsetAnimation = TimerAnimation(
    duration: duration,
    animations: { [weak self] _, time in
        self?.contentOffset = parameters.value(at: time)
    },
    completion: { [weak self] finished in
        guard finished && intersection != nil else { return }
        let velocity = parameters.velocity(at: duration)
        self?.bounce(withVelocity: velocity)
    })

In the production you should use a separate animation for each of the coordinates (x and y) to achieve correct behaviour.

About

🌹 Scroll mechanics implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages