Giter Club home page Giter Club logo

centeredcollectionview's Introduction

CenteredCollectionView

Build Status Version Carthage compatible SwiftPM compatible Swift 5.0 Platform

CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resulting in the "carousel effect" ๐ŸŽก

Example

Demo

To try the example using Cocoapods:

pod try CenteredCollectionView

Requirements

This pod requires a deployment target of iOS 9.0 or greater

Installation

CenteredCollectionView is available through Swift Package Manager, CocoaPods and Carthage.

To install it with Swift Package Manager, add the URL https://github.com/BenEmdon/CenteredCollectionView in Xcode Add Package Dependency assistant ; or add to your own Package.swift:

dependencies: [
  .package(url: "https://github.com/BenEmdon/CenteredCollectionView", from: "2.2.2")
]

To install it with Cocoapods, add the following line to your Podfile:

pod "CenteredCollectionView"

To install it with Carthage, add the following line to your Cartfile:

github "BenEmdon/CenteredCollectionView"

Usage

Checkout USAGE.md

API

Checkout API.md

Contributing

Have a suggestion? All contributions are welcome!

If you make a pull request or an issue, you're likely to get a swift response!

Author

@BenEmdon ๐Ÿ‘จโ€๐Ÿ’ป

License

CenteredCollectionView is available under the MIT license. See the LICENSE file for more info.

centeredcollectionview's People

Contributors

azarovalex avatar benemdon avatar bimawa avatar dean151 avatar horita-yuya avatar martin-key avatar monkeywithacupcake avatar peterkos avatar usefuljeroen avatar vkcldhkd avatar warpdesign 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

centeredcollectionview's Issues

cell's position is not correct when after collectionview reloading

Describe the bug
when making collectionview using centeredCollectionViewLayout in collectionViewcell.

If collectionView is reloaded, cell is not centered

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

How can we observe the centered index?

Hi,

Is there any ways to get the event like "indexAtCenter", or any approaches to observe the "currentCenteredPage" property so that we can know when and which cell has been centered?
I tried KVO on that property using RxSwift but nothing emitted after the initial value (which I set as 0 since there's no optional type in Objective-C).

Version for Swift 2.3?

Which version to use for Swift 2.3? I get errors on the latest version, as well as 0.9.3.

Slide off of last page

Requesting additional API to enable slide "beyond" the last page.

This gesture is commonly known for intro pages like this https://github.com/ealeksandrov/EAIntroView

So you would swipe. And then keep swiping. And then at some point you understand the instructions or get bored and swipe swipe swipe and it goes away.

Crash on : collectionView.indexPathForItem(at: currentCenteredPoint)?.row

collectionView.indexPathForItem(at: currentCenteredPoint)?.row

It's randomly crashing on this line: from crashlytics

log :

Fatal Exception: NSInternalInconsistencyException
UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}

Convert to Swift 4.2

When using the pod, Xcode gives a warning that the project isn't Swift 4.2.
I tested the automatic converter of Xcode, and it looks like everything would still work.
So probably a very minor change.
screenshot 2018-11-25 at 19 17 17

Not able to center the current cell in UITableviewCell.

Describe the bug
I have used the Collection view in the UITableviewcell. When I reload the cell in uitableview cell. And after reloading the Tableview when i reload the centeredCollectionViewFlowLayout.scrollToPage(index: 0, animated: true). It's not working as expected which is cell should be in the center of the screen.

Expected behavior
Should be in the center of the screen.

Screenshots
https://pasteboard.co/JoSCAZC.png

Desktop (please complete the following information):

  • OS: iOS

Smartphone (please complete the following information):

  • Device: iphone 11 pro
  • OS: ios 13

Issue with more than 4 cells- actions affect every fourth cell.

Hello,
I'm currently running the example code, except with a twist- I added a button that when clicked makes it unclickable in the future. Now, here's the problem: whenever I click on button 1, button 5 is immediately also unclickable. Could this be an issue with my code, or is it directly related to the CenteredCollectionView?
Thank you! This is such a help.

Make this a great CocoaPod

Todo

  • Refactor code to be generically used
    - [x] Turn into a framework ( #6 )
  • Example app using cocoapods
  • Make iOS deployment target 9.0 ( #7 )
  • document code
  • Write readme
  • Write podspec description
  • Gifs
  • Write unit tests
  • Publish cocoapod

Change item size which is not centered.

Is your feature request related to a problem? Please describe.
Is there any way we can change item size to smaller which is not centered?

Describe the solution you'd like
The idea is centered item should be bigger than other items.

Support iOS 13

Right now it appears that CenteredCollectionView doesn't support iOS 13 (ref #53). If anyone in the community of users would like to spare a hand, I would be more than happy to review and merge the code to make CenteredCollectionView support iOS 13.

I'll buy the person that upgrades this some coffee (via a crypto transfer).

I am also looking for a co-maintainer, if anyone is interested ๐Ÿ‘€

How to hide ControlCenter?

Hi, I adapted code from the Example project and everything is working perfectly but I'd like to disable the control center.

I've tried setting the isHidden property of the ControlCenterView to true but that broke functionality.
I tried setting the various switches and labels contained in the ControlCenterView but that also broke functionality.

What's the simplest way to remove them from the project while keeping the CenteredCollectionView in horizontal format?

This is what happens when I try to hide the ControlCenterView...
screenshotcollectionview

How to scale cells?

Hey!
I'm not good at flow layout, please help me with my task.
I need something like that:
default
So I need to scale cells where user scroll the collectionView. How can I do that, through edit your layout?
Thanks!

Why is this line needed?

if (velocity.y < 0 && offset > 0) || (velocity.y > 0 && offset < 0) {

Hi, nice library you have there. I've been wondering what is the use of that check here? it seems to be checking if the new offset doesn't lie within the natural bounds, and handle that. But isn't this already solved by the default bouncing behavior? I commented out that check, and the demo worked fine.

didChangeCenteredPage ?

Is there anyway to implement a function like didChangeCenteredPage() or something?

I have animations occurring in each of my Collection View Cells but only want the animation to happen when the Cell becomes centered.

Thanks for your help
-Alex

Is it possible to start the collectionView first cell at the beginning of the list and not centred ?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Reduce project to only be UICollectionViewFlowLayout

This will clean things up significantly, making the project more production safe.

TODO:

  • Refactor out all the UICollectionView methods to be concrete constrained extensions
  • Remove CenteredCollectionView and make CenteredCollectionViewFlowLayout main API
  • Redo example app

currentCenteredPage change event

If you use a page control controller to show the user the current page the updating is slow.

To update the controller you have to use one of the methods of protocol UIScrollViewDelegate. But they only track events around gestures, which makes the updating slow when they stop scrolling (the earlier event to update is scrollViewWillBeginDecelerating, and has a noticeable delay to update)

I think an event for changes over centeredCollectionViewFlowLayout.currentCenteredPage would solve the problem.

I tried to use observers but is not possible because is a get only property (I suppose is computed).

It's a similar problem to #16, but with "time constraints".

Please tell me if I'm missing something.

Thanks for such awesome project.

Swipe one by one cell

Hello:)
First, thank you for you made this library. It's very helpful for me.
I have a question:
Do you support scroll one by one cell?

Support self-sizing cell

Hello:)
First, thank you for you made this library. It's very helpful for me.
I have a question.
Do you support self-sizing cell?

Cell not centered

Describe the bug
The cell is not in center, but if i scroll the collection manuallt, the cell stops at center. Please check image.

Expected behavior
Cell should initially appear in center

Screenshots

img_0056
img_0057

Corner radius is not working in iPhone 6,7,8 and x but it's working fine in xr and plus models

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Support Swift Package Manager

Is your feature request related to a problem? Please describe.
Xcode 11 enabled SPM to be used as a dependency manager. Since then, SPM support for libraries would be nice ; especially for One-Class libraries like this one :)

Describe the solution you'd like
Create a Package.swift file ; to enable SPM support

Describe alternatives you've considered
Cocoapods & Carthage are nice, but they feel heavy for small projects

Additional context
If I have spare time in the next few days, I'll submit a tested PR myself ; I could use this nice minimalist lib for a side project I wanna start ;)

Swift 4

Could you update for swift 4?
Thanks!

Storyboard integration example

It would nice to have an example to show how to integrate this framework with storyboards. Since storyboards are very popular it would be very beneficial for the future of this project.

I hope to get around to this at some point but am very busy, so if someone in the community could lend a hand it would be greatly appreciated.

How to integrate this pod with Storyboard?

So I have been working around with this pod for a day by now. I wanted the UI really bad for my collection view. I tried giving my collection view on my storyboard the CenteredCollectionView class after pod install but nope. That did not work. If you don't mind sharing how to make this work with Storyboard, it will make a world of a difference. Thanks.

Clean up example app

  • Switches from vertical to horizontal
  • touch events on a cell that isn't the currentCenteredPage triggers a scrollTo

First cell not centered before touch (iOS 13)

Describe the bug
The collection is not vertically centered correctly when the view appears. The collection centers itself once I touch it (slide).

To Reproduce
Steps to reproduce the behavior:

  1. Installa Catalina and Xcode Version 11.0 beta 5
  2. Use pod try CenteredCollectionView
  3. Run project
  4. Try programmatic or storyboard examples

Expected behavior
Vertically centered collection view

Screenshots

Before Slide:

After slide:

Smartphone

  • Device: iPhone Xs Simulator
  • OS: 13.0
  • Version beta

Additional context
This bug only occurs on the beta version of iOS 13. (iPhone Xs Simulator 13.0). Everything is fine with iOS 12.

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.