Comments (3)
This is incredible. Thanks for the help. I was very stuck trying to modify things around but this made it very clear. I really appreciate this!
from verticalcardswiper.
No problem, I've been in your situation, it's not easy to implement bug-free cell based paging. Glad it helped. I'm going to close the issue for now, let me know if you still need any help (you can always reopen it).
from verticalcardswiper.
Hi @Andrew05,
This functionality is probably not going to be implemented in the near future since it would require a lot of rewriting and I'd rather get some other things fixed first.
Normally if you switch up the X and Y values you should be able to get the same results on the horizontal axis instead of vertical but you need to make sure you account for all insets etc.
I posted my solution for vertical paging in the following stackoverflow thread:
https://stackoverflow.com/questions/13492037/targetcontentoffsetforproposedcontentoffsetwithscrollingvelocity-without-subcla/49617263#49617263
I suggest you look at all the answers in this thread as most of them are meant for horizontal paging. You should be able to easily find a good solution that fits your needs there.
Hope this helps. Let me know if you still need help.
Best regards,
Joni
edit 1: If you'd still like to use this library with your own paging algorithm I suggest you just download the Source folder from github, drag it into your project and then change the contents of the targetContentOffsetForProposedContentOffset:withScrollingVelocity
function.
edit 2: After further looking into it, it looks like you'll need to change quite some things up to achieve a good result. I'd suggest you just use a UICollectionView
and build your own solution with that, you can still look into how exactly I did things and make it suit your needs.
Here's the paging function which I got working horizontally in this project:
// Cell paging
internal override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
// If the property `isPagingEnabled` is set to false, we don't enable paging and thus return the current contentoffset.
guard isPagingEnabled else {
let latestOffset = super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity)
return latestOffset
}
// Page width used for estimating and calculating paging.
let pageWidth = cellWidth + self.minimumLineSpacing
// Make an estimation of the current page position.
let approximatePage = self.collectionView!.contentOffset.x/pageWidth
// Determine the current page based on velocity.
let currentPage = (velocity.x < 0.0) ? floor(approximatePage) : ceil(approximatePage)
// Create custom flickVelocity.
let flickVelocity = velocity.x * 0.3
// Check how many pages the user flicked, if <= 1 then flickedPages should return 0.
let flickedPages = (abs(round(flickVelocity)) <= 1) ? 0 : round(flickVelocity)
// Calculate newVerticalOffset.
let newHorizontalOffset = ((currentPage + flickedPages) * pageWidth) - self.collectionView!.contentInset.left
return CGPoint(x: newHorizontalOffset, y: proposedContentOffset.y)
}
Here's a semi-working version, you'll probably need to change up quite a few things, I tried to mark everything that I changed up or probably still needs to be changed up with // CUSTOM
comments:
VerticalCardSwiper-master.zip
But I'd suggest you just start with a UICollectionView
from scratch and just use the paging algorithm. Also, I used the minimumLineSpacing
which means I'm still using rows, but I think you'd be better of using minimumInterItemSpacing
and setting sections instead of rows. Hope this helps.
from verticalcardswiper.
Related Issues (20)
- [Feature] Swipe without removing the item from the list HOT 4
- [Feature] Lower the opacity for the stacked cards HOT 3
- Expose `cellForItem` API HOT 4
- Stop Left Swipe || Increase Card Size HOT 1
- [Bug] Adding multiple card sizes doesn't snap card correctly HOT 3
- [Bug] Losing cards from stack when device orientation is rotated HOT 7
- [Question] How do I use a button on this card to launch a new ViewController> HOT 1
- How to preview card(cell) reload?[Question] HOT 2
- [Bug] `isStackOnBottom` and `stackedCardsCount` not working on 2.3.0 HOT 5
- How can I change the size of card view? HOT 1
- [Bug] Toolbar won't respond
- How do you disable vertical scrolling?
- [Question] I want to modify the alpha value according to the scroll ratio when scrolling cell
- [Question] I have a problem when scrolling, the view behind it overlaps.
- [Question] Current and Next cell with different size.
- MJRefresh failed to refresh. HOT 1
- How to scrollToCard horizontally?
- Removing the velocity animation
- utility function
- SwiftUI
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 verticalcardswiper.