Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to snap scrolling to the nearest row boundary #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattrubin
Copy link

Added @property (nonatomic) BOOL snapsToRows; to enable snapping the nearest edge of a row to the top of the calendar when scrolling ends.
This property is similar to pagingEnabled, except the snapping is to rows rather than months.
Paging takes precedence over snapping to row boundaries.

NSIndexPath *targetIndexPath = [self.tableView indexPathForRowAtPoint:*targetContentOffset];
CGRect targetCellRect = [self.tableView rectForRowAtIndexPath:targetIndexPath];
// Round the scroll finish point to the nearest cell boundary
if (targetContentOffset->y < targetCellRect.origin.y + targetCellRect.size.height/2.) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though this may be idiomatic C, I'm a bit wary of introducing this kind of struct pointer notation. Also 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants