https://github.com/maximkotliar/parallaxable
Beautiful parallax effect for your Table/Collection cells.
https://github.com/maximkotliar/parallaxable
collectionview collectionviewcell parallax swift tableview tableviewcell
Last synced: about 1 month ago
JSON representation
Beautiful parallax effect for your Table/Collection cells.
- Host: GitHub
- URL: https://github.com/maximkotliar/parallaxable
- Owner: MaximKotliar
- License: mit
- Created: 2018-06-10T12:42:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-22T00:14:20.000Z (about 5 years ago)
- Last Synced: 2025-03-20T21:54:56.062Z (2 months ago)
- Topics: collectionview, collectionviewcell, parallax, swift, tableview, tableviewcell
- Language: Swift
- Homepage:
- Size: 437 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://cocoapods.org/pods/Parallaxable)
[](http://cocoapods.org/pods/Parallaxable)
[](http://cocoapods.org/pods/Parallaxable)# Parallaxable
Beautiful parallax effect for your Table/Collection cells. (Or something else)
## Installation
Add`pod 'Parallaxable'`
to your podfile, and run
`pod install`
## Usage
Out of the box, Parallaxable calculates parallax offset for any collection/table cell.For enable calculation you need to set:
```swift
tableView.isParallaxEnabled = true
```Also you need to conform protocol `Parallaxable` with your cell like:
```swift
let parallaxOffsetMultiplier: CGFloat = 20
extension TableCell: Parallaxable {
func updateVerticalParallaxOffset(with offset: CGFloat) {
var targetCenter = contentView.center
targetCenter.x = imageView.center.x
targetCenter.y += offset * parallaxOffsetMultiplier
imageView.center = targetCenter
}func updateHorizontalParallaxOffset(with offset: CGFloat) {
var targetCenter = contentView.center
targetCenter.x += offset * parallaxOffsetMultiplier
targetCenter.y = imageView.center.y
imageView.center = targetCenter
}
}
```
Code above will offset `TableCell`'s imageView from center by `offset`.`offset` is value from `-1` to `1` representing position of cell relative to table/collection view's center.