vishal-singh-panwar / infinitescrolling Goto Github PK
View Code? Open in Web Editor NEWAdd infinite scrolling to collection view.
License: MIT License
Add infinite scrolling to collection view.
License: MIT License
Hi,
awesome work you did there. I am trying to port this functionality to Xamarin iOS via C#.
Almost everything works out fine, except when I scroll and it reaches the points where content offset should be updated it stops the scrolling animation and stops.
I had similar problems with my own implementation, that's why I found yours in the first place.
Do you have any idea why is this happening? My calculations and numbers are exactly like yours. Am I missing some property or config which discards animations when contentOffset is updated?
public override void Scrolled(UIScrollView scrollView)
{
var boundarySize = Parent._numberOfBoundaryElements * (Parent.CellSize + Parent.Padding);
var contentOffsetValue = Parent.ContentOffset.Y;
if (contentOffsetValue >= Parent.ContentSizeValue - boundarySize)
{
var offset = boundarySize - Parent.Padding;
var updatedOffsetPoint = new CGPoint(0, offset);
scrollView.ContentOffset = updatedOffsetPoint;
}
else if (contentOffsetValue <= 0)
{
var boundaryLessSize = Parent.DataSet.Count * (Parent.CellSize + Parent.Padding);
var updatedOffsetPoint = new CGPoint(0, boundaryLessSize);
scrollView.ContentOffset = updatedOffsetPoint;
}
}
On this gif the black shoes is the first item where the contentOffset is updated.
I am attempting to use the horizontal infinite scroll to display compass values (0 - 359). As the compass data is updated, I attempt adjust the display using:
func setCompassHeading(heading: Int) {
let ip = IndexPath(item: heading, section: 0)
self.collectionView.scrollToItem(at: ip, at: .centeredHorizontally, animated: true)
}
Values passed are 0 - 359. I expect the collection view to move to the indicated item. However, it is alway off by some number of items. The number of items by which it is off is dependent on the width of the screen. The collection view's width is managed by AutoLayout and adjust depending on if the device (an iPad) is in portrait or landscape mode.
My best guess is that some factor - the width of the items, the spacing between them - is calculated once at load and does not get recalculated after the AutoLayout system has updated the display.
Any suggestions on fixing this? Thanks!
Is it possible to manually set cell size?
i.e. full CGSize not only one param?
Is it possible to scroll the collection view using code, for a long time just like casino slots?
i want to implement pagination, after scroll ended, it should be spanned to the nearest center item.
any suggestion to achieve this? please? :)
I think we need flexible size to calculate size of cell
public enum LayoutType {
case flexible(lineSpacing: CGFloat)
}
public protocol InfiniteScrollingBehaviourDelegate: class {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
}
I have 10 fix indexpaths and on each indexpath it should diff. color and image. So i've place a conditional block in following method
func configuredCell(forItemAtIndexPath indexPath: IndexPath, originalIndex: Int, andData data: InfiniteScollingData, forInfiniteScrollingBehaviour behaviour: InfiniteScrollingBehaviour) -> UICollectionViewCell { }
But its not returning the correct indexpath. Can any1 from here help me to out
Hi,
I noticed an issue in implementing UIPageControl with InfiniteScrolling control as I don't get an option to find the currentPage or scrollview instance from InfiniteScrollBehaviourDelegate. I have seen that this library is last updated an year back.
Apart from the above mentioned, I am completely happy to integrate this library in my project. If you can let me know a solution, which will be much helpful for me.
Thanks,
Bruce.
We're using this component and getting the occasional crash upon calling updateConfiguration
inside the InfiniteScrollingBehavior
class.
The scenario is as we have a vertically scroll UICollectionView
where each cell in the collection view contains another collection view that uses the InfiniteScrollingBehaviour
class. Each time we deque and reuse a cell we need to call updateConfiguration
on the InfiniteScrollingBehavior
, and this is where the crash occurs. We can't reproduce it 100% of the time, but it happens frequently enough that it would blow up in production if we were to release it.
I'm suspecting that
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self.collectionView.reloadData()
self.scrollToFirstElement()
}
is causing the problem. May I ask, why you have used a asyncAfter
call, rather than just a async
? Also, why do we need to use DispatchQueue.main
at all, as the InfiniteScrollingBehavior
doesn't perform updateConfiguration
on a background queue?
i'm getting this error Division by zero in remainder operation. thx
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.