Comments (8)
@MaherKSantina
this issue can be closed
from mspeekcollectionviewdelegateimplementation.
Thanks @ssamkough for contributing to this repo by raising this issue!
I was wondering are you using the latest version of the library?
If yes, can you try this for me:
Print out the frame width for the peeking collection view and see if it's the same as the device's frame. I can see that the scrolling doesn't work for the subsequent collection items as they are cut off and not shown in center properly.
Seems that the calculation of the offset of items is not correct
The ideal case for me would be if you're able to share with me a minimal example project that has the issue, this way I'm able to investigate it properly and work on a fix
from mspeekcollectionviewdelegateimplementation.
I am using version 3.1.1.
I will print the values and tell you what I see. In the meantime, here is an example of my project:
import MSPeekCollectionViewDelegateImplementation
class FeedController: UITableViewController {
var posts = [Post]()
var behavior: MSCollectionViewPeekingBehavior!
override func tableView(_ tableView: UITableView,
willDisplay cell: UITableViewCell,
forRowAt indexPath: IndexPath) {
behavior = MSCollectionViewPeekingBehavior(cellSpacing: 15)
cell.taggedProductsCollectionView.configureForPeekingBehavior(behavior: behavior)
cell.taggedProductsCollectionView.delegate = self
cell.taggedProductsCollectionView.dataSource = self
}
override func scrollViewWillEndDragging(_ scrollView: UIScrollView,
withVelocity velocity: CGPoint,
targetContentOffset: UnsafeMutablePointer<CGPoint>) {
behavior.scrollViewWillEndDragging(scrollView,
withVelocity: velocity,
targetContentOffset: targetContentOffset)
}
}
extension FeedController: UICollectionViewDataSource,
UICollectionViewDelegate,
UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return posts[collectionView.tag].taggedProducts.count
}
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: "taggedProductCell",
for: indexPath) as? TaggedProductCell else {
fatalError("Unexpected index path, problem dequeuing resuable cell.")
}
let taggedProduct = self.posts[collectionView.tag].taggedProducts[indexPath.item]
cell.taggedProduct = taggedProduct
cell.taggedProductDelegate = self
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let taggedProduct = self.posts[collectionView.tag].taggedProducts[indexPath.item]
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 10
layout.minimumInteritemSpacing = 10
collectionView.scrollToItem(at: indexPath, at: .bottom, animated: false)
layout.sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
collectionView.setCollectionViewLayout(layout, animated: false)
}
}
from mspeekcollectionviewdelegateimplementation.
Print out the frame width for the peeking collection view and see if it's the same as the device's frame. I can see that the scrolling doesn't work for the subsequent collection items as they are cut off and not shown in center properly.
By the peeking collection view do you mean the collection view, or just the peeking part of it? Because the collection view is the same size as the device (using constraints), but each item has a custom width of 373. This is all configured within a storyboard.
from mspeekcollectionviewdelegateimplementation.
Hey @ssamkough really sorry I didn't receive a Github notification for your comments 😢 Okay so let's do a little debugging. Can you try to move the whole collection view outside the cell? Like have it directly in the view controller? I'm expecting that having the collection view inside a table view cell will cause the frames not to be calculated properly. If the collection view behaves properly there, then I think you might need to initialize the peeking and everything in the viewDidLayoutSubviews function. This way we're sure that the frame calculations are all done by then
Hope that helps, especially that it's 20 days late 😢
from mspeekcollectionviewdelegateimplementation.
Hello @MaherKSantina
I am also experiencing the same issue.
I have a collectionView inside UITableViewHeaderFooterView
.
When using cellPeekWidth the scroll calculations are wrong. If set to 0 the scrolling is correct.
I tried to put the initialize of the behaviour inside layoutSubviews()
I even tried to set the collectionViewFrameWidth same as the device's width before creating the behaviour
collectionView.frame.size.width = UIScreen.main.bounds.width
in order to have correct calculations, but that didn't help either.
from mspeekcollectionviewdelegateimplementation.
@MaherKSantina
here you can find my example implementation:
https://github.com/alexookah/MSPeekCollectionView-Example
from mspeekcollectionviewdelegateimplementation.
I resolved the issue @ssamkough @MaherKSantina.
If the collectionView is inside a tableview it needs:
collectionView.isPagingEnabled = false
Something similar exists in UICollectionView+PeekConfiguration.swift
:
collectionView.configureForPeekingDelegate()
from mspeekcollectionviewdelegateimplementation.
Related Issues (20)
- Scrolling with 0 velocity will not land on the correct page HOT 11
- Add support to animate peeking items while scrolling HOT 1
- Where is MSPeekImplementationDelegate now? HOT 3
- Add SPM Support HOT 2
- Alignment horizontal scroll collection view HOT 6
- Is it possible to change the view content of center one? HOT 3
- RxCollectionView only shows one cell always HOT 1
- sizeForItem delegate function is not called when peek behavior is configured HOT 6
- Use of undeclared type 'MSCollectionViewPeekingBehavior' HOT 4
- Use of undeclared type 'MSCollectionViewPeekingBehavior' HOT 1
- extra space !? HOT 4
- MSPeekImplementationDelegate returns under/over index in race conditions HOT 5
- Top and Bottom spacing of UICollectionViewCell cut HOT 2
- Crash on behavior.scrollViewWillEndDragging call in v3.1.1
- SPM Fail HOT 1
- Backward scroll
- Scroll bars not visible
- can't change cell size and positioning
- Mistakenly created
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mspeekcollectionviewdelegateimplementation.