GithubHelp home page GithubHelp logo

kelvinjin / animatedcollectionviewlayout Goto Github PK

View Code? Open in Web Editor NEW
4.7K 72.0 347.0 2.11 MB

A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.

License: MIT License

Ruby 9.42% Swift 88.76% Objective-C 1.82%
swift uicollectionview uicollectionviewlayout-subclass transition animation ios cocoapods

animatedcollectionviewlayout's People

Contributors

colorbox avatar filograno avatar kelvinjin avatar naldikt avatar zhongwuzw 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  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

animatedcollectionviewlayout's Issues

Animator folder did not included

Do i need to copy the Animator folder or did i do something wrong that the code can not recognized the animator? Even though i see in your commit message that you fixed the issue the pod didn't include the animator? Thank @KelvinJin

fast scrolling? (enhancement)

Where would I alter the code to allow fast scrolling? By fast scrolling, I am referring to the fact that the current animations allow "one cell at a time" scrolling, rather than the typical UIScrollView scrolling.

In particular, what I think would be useful would be to allow for fast scrolling and then upon stopping (either manually, or once the animation finishes), snapping to the closest cell.

I know the author of this is busy, but if someone could point me in the right direction, perhaps I can create a pull request and work on it myself.

How to adjust collectionView Cell size appropriately when in landscape?

I'm using your current projects master branch. When I run the project the Parallax Collection view in portrait it looks great. The issue is when I turn it landscape the cells do not resize property( The experience should be the same as portrait - only one cell showing). Could you please fix this issue on a separate branch? Thank you!

Here is an image illustrating the issue:

Parallax-Image

Can`t use with Cocoapods

screenshot

Thanks to your nice library.

But cannot use with Cocoapods...

is it a temporary problem or not use with Cocoapods?

Autoplay feature

Hi,
I'm working with an autoplay feature and have two questions.

First one is that to go to next indexPath, I'm using the scrollToItem function, but is not always working as expected, sometimes it scrolls and sometimes not.

collectionView.scrollToItem(at: nextIndexPath, at: UICollectionViewScrollPosition.left, animated: true)

Maybe I'm missing something here..

And second, there's a way to change the speed of the animation of scrollToItem? Looks it's fixed by the system..

Thanks!

Wrap?

Is it possible to override this layout, and make the cells wrap? IE: when the collection view gets to the last index, it animates back to the first.

Doesn't work for RLT layout

The CubeAttributesAnimator animation does not display correctly in Right-to-Left layouts, e.g. for Arabic language.
When setting the flipsHorizontallyInOppositeLayoutDirection = true, the animation is not displayed correctly.

Version for Swift 2.3?

I tried 0.1.2 on Swift 2.3 and apparently I get errors. Is there a version supported by Swift 2.3?

Scroll by button tap

Hi.
I trying to add the possibility for scroll left/right by a button tap.
It is possible? Please help someone.

In "#selector" i put code below, but it not work :

mainCollection.scrollToItem(at: IndexPath(item: item, section: 0), at: .centeredHorizontally, animated: true)

Thanks

Library Usage

problem

after i followed the thing, i got this as result.

It doesnt seem like it working right. Just a normal CollectionView and even the snap is not on point. Can you help me with this? I am newbie.

the following code

super.viewDidLoad()

        animator = (ParallaxAttributesAnimator(), true)
        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Register cell classes
//        self.collectionView!.register(SimpleCollectionViewCell.self, forCellWithReuseIdentifier: "CollectionCell")
//        
//        self.collectionView?.register(<#T##cellClass: AnyClass?##AnyClass?#>, forCellWithReuseIdentifier: <#T##String#>)

        // Do any additional setup after loading the view, typically from a nib.
        
        // Must turn paging on.
        collectionView?.isPagingEnabled = true
        
        if let layout = collectionView?.collectionViewLayout as? AnimatedCollectionViewLayout {
            layout.animator = animator?.0
        }

get indexpath

when i scroll i need index path. how can i get that indexpath.??

Vertical ?!

Can I use the animations for vertical scroll ( I need "Page" animation ) ??

Scroll like animation on the click of Button

hey! well this works well while we have UICollectionViewCtr when we try to Customize it to ViewController By just setting flowLayout of CollectionView.

Now i have left and right button and i want the same Procedure of scroll animation on the click of these two button Action.

if any one have performed this then please help.

CubeAttributesAnimator Not Working

Firstly thank you for this library, exactly what i need is the library :) I tried all of Attributes Animators, they all working well but CubeAttributesAnimator not working.

CubeAttributesAnimator screen display is strange.

Description

Hi,

I use this library and choose CubeAttributesAnimator in my iOS app, but screen display is strange. When I implement photo gallery with full screen, I can only see half photo.
I think it seems to be caused by a bug of internal animation logics.

thanks :)

Environments

AnimatedCollectionViewLayout Version: 1.0.0
Xcode version: 11.1
Swift version: 5.1
Platform(s) running AnimatedCollectionViewLayout: iOS
macOS version running Xcode: 10.15.1

ScreenShots

Strange Finished Pagination:

Strange_Finished_Pagination

Expected Collect State Finished Pagination:

Expected_Collect_State_Finished_Pagination

Animation not working

When I run the app the collectionView shrinks each cell and displays them all at once on the screen.

I followed readme and added this to my viewDidLoad()


let layout = AnimatedCollectionViewLayout()
layout.animator = ParallaxAttributesAnimator()
collectionView.collectionViewLayout = layout 

Card layout

is it possible to make card layout size smaller. i mean to display two cell in one screen?if its possible how can i achieve that ?

How do we add spacing between cells for parallax effect?

I'm currently trying to set spacing between my collection view cells. The issue is every time I scroll horizontally the cell does not reset back to where is should be.

Please Look at image bellow!

Here is my code:

extension ImageCollectionViewController: UICollectionViewDelegateFlowLayout {
override func numberOfSections(in collectionView: UICollectionView) -> Int {
    return 1
}

override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return Int(Int16.max)
}

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let c = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath)

    if let cell = c as? SimpleCollectionViewCell {
        let i = indexPath.row % vcs.count
        let v = vcs[i]
        cell.bind(color: v.0, imageName: v.1)
        cell.clipsToBounds = animator?.1 ?? true
    }

    return c
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    guard let animator = animator else { return view.bounds.size }
    return CGSize(width: view.bounds.width / CGFloat(animator.2), height: view.bounds.height / CGFloat(animator.3))
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
    return .zero
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
    return 10
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 0
}
}

Also here are images showing what happens:

CollectionView

custom item size

How to customize item size?(eg: LinearCardAttributesAnimator

status bar is not visible

I am wondering why the status bar not visible in the collection view. would you mind helping me make it visible?

Customising UI

I like LinearCardAttributesAnimator() but I need to customize it. Is it possible to make it more linear, without zoom effect and place cells very close to each other?

How to make parallax cell not effect text?

Right not it seems like the Parallax effects the background of the cell and what's in front. I was wondering if there is a way to change this so the text on the cell is not effected by Parallax? Therefore the "Text/UILabel" does not move with the Parallax as you scroll?

How to make an animation for one element?

Hello! I want to do an animation for one element, for example if the user has one item in the collection, so that he can at least scroll to the left or right (as with default behavior). What is the best way to implement this? Thanks.

Layout wrong on iOS 10

Hi,
I use CubeAttributesAnimator and setup in viewDidLoad
layout.animator = CubeAttributesAnimator(perspective: -1 / 800, totalAngle: .pi / 4) layout.scrollDirection = .horizontal layout.invalidateLayout()
but layout broken on CollectionView,
`func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
    return .zero
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
    return 0
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 0
}`

Simulator Screen Shot - iPhone 5s - 2020-04-08 at 15 22 30

RotateInOut - Cells are not vertical @ center

I'm seeing that cells are not centered in RotateInOut (and other animators) - meaning at the center position of the scroll - using isPagingEnabled - the cell is rotated.

let layout = AnimatedCollectionViewLayout()
layout.animator = RotateInOutAttributesAnimator(minAlpha: 1)
myChartCollectionView.collectionViewLayout = layout
myChartCollectionView.frame = CGRect(x: 0, y: 144, width: 414, height: 718)
layout.itemSize = CGSize(width: 384, height: 624)
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
myChartCollectionView.isPagingEnabled = true
layout.scrollDirection = .horizontal

myChartCollectionView.dataSource = self
myChartCollectionView.delegate = self

Is this a bug in the center/rotation calculator AnimatedCollectionViewLayout or a setting/config I'm missing? TY!

Version 0.3.0 and version 0.2.0 bug

I use AnimatedCollectionViewLayout a bit differently by storing UITableViews and UITableViewCells in them with the parent UIViewController referenced with a protocol. In other words, it's architected like so:

UITableViewCell --> UITableView --> UICollectionViewCell --> UICollectionView --> UIViewController (using AnimatedCollectionViewLayout)

The parent class using this framework may or may not return a UICollectionViewCell with a UITableView init, and all the UITableViewDataSource and Delegate methods are managed in the parent class (we used our own protocol to do this). BUT, when I updated to version 0.3.0, the frames are frozen when the transition occurs. The animator used is the

ParallaxAttributesAnimator

I think the error occurs because of one of the return values in the animations. Please take a look when you can, and if you need help feel free to reach out!

Hello, I would like to ask how to write the following layout.

How to achieve equal spacing between items?

iPhone X Max

Simulator Screen Shot - iPhone 8 - 2019-07-13 at 11 03 58

private func configureAttributes(for attributes: UICollectionViewLayoutAttributes) {
    guard let collection = collectionView else { return }
    var visibleRect = CGRect()
    visibleRect.origin = collection.contentOffset
    visibleRect.size = collection.bounds.size
    let collectionLeft =  itemSize.width / 2
    let offset = collection.contentOffset.x
    let normalizedLeft =  attributes.center.x  - offset

    let maxDistance =  self.itemSize.width
    let distance = min(abs(collectionLeft - normalizedLeft), maxDistance)
    let ratio = (maxDistance - distance)/maxDistance
    let scale = ratio * (1 - sideItemScale) + sideItemScale

    var t = CATransform3DIdentity
    t = CATransform3DScale(t,  scale, scale, 1.0)
    attributes.zIndex = Int(scale * 10)
    attributes.transform3D = t

}

RTL Support

is it still not supporting rtl language ?
when making "flipsHorizontallyInOppositeLayoutDirection" true
the animation is very corrupted

Smooth transition from the first or last cell to the previous controller.

Hello! Thanks for this framework! I use the Cube, I have a UIViewController that is completely filled with UICollecitonView, I want to achieve this result when the user swiping away on the last page (to the left) and first page (to the right) then hide the UIViewController with this animation. Tell me how best to do 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.