maherksantina / mspeekcollectionviewdelegateimplementation Goto Github PK
View Code? Open in Web Editor NEWA custom paging behavior that peeks the previous and next items in a collection view
License: MIT License
A custom paging behavior that peeks the previous and next items in a collection view
License: MIT License
I want to get the active index i implemented MSPeekImplementationDelegate the implementation is correct I already double checked everything The
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int)
is not being called.
This is my implemetation:
peekImplementation = MSPeekCollectionViewDelegateImplementation()
collectionView.configureForPeekingDelegate()
peekImplementation.delegate = self
peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: 0, cellPeekWidth: 0, scrollThreshold: 1, maximumItemsToScroll: 5, numberOfItemsToShow: 1)
collectionView.delegate = peekImplementation
collectionView.dataSource = self
Hi there!
I'm coming across an issue where my item gets cut off before showing it's full contents. I've attached a video of me using it.
If we drag a bit backwards to the previous page and remove our finger, the paging will always go to the previous page. The expected behavior should be to stay on the current page if the threshold is low
Same goes to when scrolling to the next page with no velocity, no matter how much we scroll, we'll always end up on the current page. The expected behavior is to go to the next page if the scroll is greater than the threshold
Works fine with one section in collection view, but I don't know if it could with multiple sections? I find that it has larger space between sections than cells. and could be problem with scrolling.
This function will help users to scroll to a specific item programmatically.
If the items are small, the user might want to scroll more than one item at a time
I've implemented my collection views this way :
mapCollectionView.configureForPeekingDelegate()
delegate = MSPeekCollectionViewDelegateImplementation()
delegate = MSPeekCollectionViewDelegateImplementation(cellSpacing: 5)
delegate = MSPeekCollectionViewDelegateImplementation(numberOfItemsToShow: 3)
delegate = MSPeekCollectionViewDelegateImplementation(cellPeekWidth: 5)
mapCollectionView.delegate = delegate
mapCollectionView.dataSource = self
shortcutCollectionView.configureForPeekingDelegate()
shortcutDelegate = MSPeekCollectionViewDelegateImplementation()
shortcutDelegate = MSPeekCollectionViewDelegateImplementation(numberOfItemsToShow: 4)
shortcutCollectionView.delegate = shortcutDelegate
shortcutCollectionView.dataSource = self
shortcutCollectionView.backgroundColor = .clear
and when calling func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath)
it seems like the function doesn't detect any of the collection vies that are implemented, swift doesn't seem to go through the function.. .
If you guys have any tips i'll be greatufull :)
First, thanks for your framework it has helped a lot!
I have an issue: My custom UICollectionViewCell has a shadow at the bottom, but MSPeekCollectionViewDelegateImplementation is cutting the shadow. Is there a way to add extra spacing to top and bottom between the UICollectionViewCell and collectionView height so the shadow appears?
Thanks!
Hello, thanks for this nice implementation, but why did you drop support of iOS 9.3 starting from v. 1.2.0? It works perfectly on iOS 9 and no need for additional legacy code.
Act more like isPagingEnabled.
If the velocity of EndDragging is zero, use "if scrollDistance more than half the page width" to decide destinationIndex, instead of "scrollThreshold". #52 #
Is MSPeekImplementationDelegate deprecated in the latest versions?
If so, how to get the current active index?
Thanks.
behavior = MSCollectionViewPeekingBehavior(cellSpacing: 0)
behavior = MSCollectionViewPeekingBehavior(cellPeekWidth: 0)
behavior = MSCollectionViewPeekingBehavior(minimumItemsToScroll: 1)
behavior = MSCollectionViewPeekingBehavior(maximumItemsToScroll: 1)
behavior = MSCollectionViewPeekingBehavior(numberOfItemsToShow: 1)
leagueCollectionView.configureForPeekingBehavior(behavior: behavior)
why this extra space !!?
cell
Currently, this lib forces the cross axis size of a cell to match that of the collection view. The App Store has another type of horizontally peeking collection view where multiple cells are displayed vertically in each page. The lib could allow specifying the number of cross-axis items to show, then use that value to calculate the appropriate item size in the collectionView:layout:sizeForItemAt:
delegate func.
Hey, there's an issue when switching orientation.
When I tried to select programmatically a cell, the selected cell is scrolled weirdly
Here is my codes:
var selectedItemIndex = 0
func selectAnItem(){
let itemContentOffset = peekImplementation.scrollView(collectionView, contentOffsetForItemAtIndex: selectedItemIndex)
collectionView.setContentOffset(CGPoint(x: itemContentOffset, y: 0), animated: false)
}
override func viewWillLayoutSubviews() {
selectAnItem()
}
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int) {
print("Changed active index to \(activeIndex)")
selectedItemIndex = activeIndex
}
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath) {
print("Selected item at \(indexPath)")
}
For users having this issue, you can do this:
override func draw(_ rect: CGRect) {
super.draw(rect)
self.collectionView.collectionViewLayout.invalidateLayout()
self.selectAnItem()
}
Good morning Maher! again thanks for your work.
I'm having a doubt, I'm using RxCollectionView and in that case the dataSource it's
fileprivate func dataSource() -> RxCollectionViewSectionedReloadDataSource
and MSPeek collectionView it's only showing one cell in all cases...
Do you have any idea, what can I do?
Thanks!
After installing the pod pod 'MSPeekCollectionViewDelegateImplementation' and using it in a ViewController. I get this error on declaration of behaviour variable
var behavior: MSCollectionViewPeekingBehavior!
Error: Use of undeclared type 'MSCollectionViewPeekingBehavior'
I want to congratulate you for this lib, it's very cool. However, I think one key feature is missing and it is an active cell support. Is there a way to easily understand (from the controller) which cell is active?
It would be really nice if the peeking items have some animations (maybe like growing/shrinking) while we scroll.
Listen for index change. Ive done exactly as on the docs. But current index Index change part doesn't work
Hey,
any idea hot to align horizontal collection view items to left when it is first item then after that could work normally with centered item. Like AppStore product carousel ...
After installing the pod pod 'MSPeekCollectionViewDelegateImplementation' and using it in a ViewController. I get this error on declaration of behaviour variable
var behavior: MSCollectionViewPeekingBehavior!
Error: Use of undeclared type 'MSCollectionViewPeekingBehavior'
Also adding initialization variables as inspectables
Add numberOfItemsToShow
parameter which specifies how many cells need to be shown at the same time
MSPeekImplementationDelegate method:
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation,
didChangeActiveIndexTo activeIndex: Int)
Returns -1 if continuous fast swipe attempts made to go below the first cell...
or returns dataSource.count if trying to swipe beyond max cell.
This only happens when I really push it and swipe super fast.
Device: iPhone SE running 13.3.1
Xcode 11.3.1
Installed via cocoapods
pod 'MSPeekCollectionViewDelegateImplementation', '~> 2.0.0'
Currently, the safe area is ignored. If a collection view is rendered on an iPhone X in landscape, the cells under run the safe area. A workaround is to add the left or right safe area inset to the cellPeekWidth
and reconfigure the delegate implementation when the view transitions sizes. Easy enough, but feels like it should be handled automatically or as another configuration argument.
Great Thanks to your repo , do you have plan to support dynamic cell width please? thanks again
I am not able to use UICollectionViewDelegate when I am using MSPeekImplementationDelegate
how can i set only left peek width 0, change to cell origin not working.
Add unit tests for scroll behavior
When i set the collection view x axis as -60 to avoid cell peek width and first item is auto scrolling after swiping the collection view. How to avoid this issue?
After updating to v3.1.1 the app crashes when releasing finger after a swipe. It works without any change with the 2 previous versions.
behavior.scrollViewWillEndDragging
callbehavior
is not nilfunc scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
behavior.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
}
Didn't see anything in the changelogs that would explain this sudden crash.
Any ideas why this is happening ?
This repo helped me immensely! There is one issue I am not sure of is how to get the scrolling or delegate methods to work when my collection view is a subview of a scroll view. It seems like the collection view stopped working completely when on a scroll view.
@objc optional func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath)
doesn't work and not even appears on the autocomplete in Xcode.
Checking MSPeekCollectionViewDelegateImplementation from the Pod project it seems it is not in the MSPeekImplementationDelegate. Only the following is shown:
public protocol MSPeekImplementationDelegate: AnyObject {
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int)
}
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int)
seems to be working fine.
And my current implementation is as below:
let peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: 16.0, cellPeekWidth: 16.0)
collectionView?.dataSource = self
collectionView?.configureForPeekingDelegate()
collectionView?.delegate = peekImplementation
peekImplementation.delegate = self
Am I missing something?
For iPhone 8, if spacing is greater than 50, going to the third cell and then going back to the second cell doesn't work
Got this error -> Specs satisfying the MSPeekCollectionViewDelegateImplementation
dependency were found, but they required a higher minimum deployment target
Hi there,
I noticed that when I have MSPeekCollectionViewDelegateImplementation implemented, that my collectionView's sizeForItem
delegate function is not called. I'm not sure why though. Is this expected or perhaps I have a bug in my code? sizeForItem
is called as expected when the peeking behavior is not configured.
I need to be able to configure my item's size while also implementing peek behavior. Does anybody have any advice?
Add a segmented control in example for changing between vertical and horizontal collection view layouts
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.