GithubHelp home page GithubHelp logo

vishal-singh-panwar / infinitescrolling Goto Github PK

View Code? Open in Web Editor NEW
214.0 214.0 39.0 66 KB

Add infinite scrolling to collection view.

License: MIT License

Swift 89.12% Ruby 8.16% Objective-C 2.72%
collectionview infinite-scroll ios-swift pagination

infinitescrolling's People

Contributors

ilockett avatar kahunasystems avatar vishal-singh-panwar 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

infinitescrolling's Issues

Port to C# - help

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;
    }
}

infinitescroll-bug

On this gif the black shoes is the first item where the contentOffset is updated.

Incorrect Position After scrollToItem(at: indexPath, ...)

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!

Scrolling through code

Is it possible to scroll the collection view using code, for a long time just like casino slots?

To need flexible size

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
}

Indexpath is returning wrong

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

Enquire feature availability in Infinite Scrolling

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.

Crash on `updateConfiguration` method

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?

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.