pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

Direction to Scroll #33

Open bercik0291 opened 8 years ago

bercik0291 commented 8 years ago

add ability to choose direction of infinity scroll (top or bottom).

pronebird commented 8 years ago

Hi @bercik0291,

I just pulled your fork and it works very well! Apart from couple of minor issues, great work! I'll see if I can find some time over weekend to refine your PR.

Thank you!

bercik0291 commented 8 years ago

@pronebird Ok, thanks for review, I will fix everything during this weekend

MHX792 commented 8 years ago

The PR unfortunately does not work with JSQMessagesViewController. The reload spinner doesn't appear.

Flitskikker commented 8 years ago

Any updates on this? @bercik0291 @pronebird

Kacper20 commented 7 years ago

Hi there,

Any update on this? @bercik0291 @pronebird Would be really cool to have a possibility to do so in this library.

Flitskikker commented 7 years ago

I'll post my workaround as mentioned in #30 here as well:

I'm currently using the following workaround for this.

For my table view:

class UIReversedTableView: UITableView {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.transform = CGAffineTransformMakeScale(1, -1)
    }
}

For my table view cells:

class UIReversedTableViewCell: UITableViewCell {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.transform = CGAffineTransformMakeScale(1, -1)
    }
}

In my view controller (viewDidLoad):

// Invert infinite scrolling indicator
let indicator = UIActivityIndicatorView(activityIndicatorStyle: .Gray)
indicator.transform = CGAffineTransformMakeScale(1, -1)
self.tableView.infiniteScrollIndicatorView = indicator

// Hide repeated lines
self.tableView.tableFooterView = UIView()

Looks hacky, but works surprisingly well thus far for me. No need to inverse your data either. 😄

Kacper20 commented 7 years ago

@Flitskikker How does it work without inverting your data? I think that messages supposed to be in reversed order after these operations. Or am I wrong?

Flitskikker commented 7 years ago

@Kacper20 It works by first mirroring the whole UITableView vertically, and then mirroring the individual cells vertically. That way, the order is reversed without altering the data source. Also the scroll direction is reversed, including the infinite scrolling.

image

The activity indicator is also mirrored, so I create a new already mirrored activity indicator, so that the resulting activity loader will look normal (actually it's mirrored twice).

Why mirror vertically instead of rotating 180 degrees? Then the swipe actions still work normally (from the right hand side)!

Kacper20 commented 7 years ago

Thanks for explanation @Flitskikker. I was meaning, that to maintain old positioning(oldest message "A" first on the list) you'd have to reverse your data source too.(now you have C, B, A).

Cheers,

pronebird commented 7 years ago

@Flitskikker @Kacper20 haven't had time to revisit this. This PR has to be refined and merged with existing master.

alizainprasla commented 7 years ago

How to use it? is it merged in current commit?

sasojadrovski commented 7 years ago

Hey @pronebird @bercik0291,

Could you please take a look at this and merge it when ready. Or any update on when to expect it?

Thanks in advance!

pronebird commented 6 years ago

@sasojadrovski there are issues with this PR and I left comments long ago but I don't think there's been any progress on this since then. :/