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

Bounce Area Background / Reduced required pull distance #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Bounce Area Background / Reduced required pull distance #9

wants to merge 2 commits into from

Conversation

mmackh
Copy link

@mmackh mmackh commented Jul 28, 2012

The background for the bounce area is shown both in Apple's mail and contacts app.

If a project uses both a Navigation & toolbar, the scroll distance of 53 in landscape doesn't work. I've reduced it to 36.

- Bounce area background
- Requires shooter pull quester (landscape compatible)
@Sephiroth87
Copy link
Owner

Regarding the background issue, I don't understand why you don't simply change the refreshControl background color.
Doing it your way the color is fixed, and that's not always the case (see the PassBook app).

For the second issue, it's a bit more complicated than that.
The scroll distance of 53 is the right one, 36 is too small.
The problem is that in the apple application, the tableView gets dragged with less friction, so you can reach the right distance.
I'm trying to understand how to do that, I'll post something when I'm done...

@cdzombak
Copy link

(gentle ping) - do you have any additional thoughts on how to resolve this yet?

@Sephiroth87
Copy link
Owner

Thoughts have been given, but time has not been found :/

@neils4fun
Copy link

This thread looks old, but if folks are still interested in this issue of being able to pull the refreshcontrol when in landscape I've implemented a solution that is working for me. I've applied an acceleration factor to the stretching of the control, so it effectively snaps and pops faster. I'm applying this universally but it would be better to apply different factors in landscape than in portrait (an acceleration factor of 1 will result in existing behavior). The code waits until the pull has exceeded a threshold amount of kOpenedViewHeight, after that it applies an effectiveOffset that uses the acceleration factor to speed up the stretch growth of the control.

I'm not very good with git so I don't know how to offer this via my own commit so I'm pasting in code into this comment.

// define the acceleration factor
#define kAccelerateFactor 2.5

// in observeValueForKeyPath replace code that starts at the line: _lastOffset = offset; with:

CGFloat effectiveOffset;
if (offset < -kOpenedViewHeight) {
    // If the scrollview is pulled past the threshold point for stretching then compute an effective offset that is equal to the threshold amount plus
    // (an accelaration factor times the delta offset past the threshold)
    effectiveOffset = -kOpenedViewHeight + ((offset + kOpenedViewHeight) * kAccelerateFactor);
} else {
    effectiveOffset = offset;
}
DDLogVerbose(@"effective offset is %f", effectiveOffset);

_lastOffset = effectiveOffset;

BOOL triggered = NO;

CGMutablePathRef path = CGPathCreateMutable();

//Calculate some useful points and values
CGFloat verticalShift = MAX(0, -((kMaxTopRadius + kMaxBottomRadius + kMaxTopPadding + kMaxBottomPadding) + effectiveOffset));
CGFloat distance = MIN(kMaxDistance, fabs(verticalShift));
CGFloat percentage = 1 - (distance / kMaxDistance);

CGFloat currentTopPadding = lerp(kMinTopPadding, kMaxTopPadding, percentage);
CGFloat currentTopRadius = lerp(kMinTopRadius, kMaxTopRadius, percentage);
CGFloat currentBottomRadius = lerp(kMinBottomRadius, kMaxBottomRadius, percentage);
CGFloat currentBottomPadding =  lerp(kMinBottomPadding, kMaxBottomPadding, percentage);

CGPoint bottomOrigin = CGPointMake(floor(self.bounds.size.width / 2), self.bounds.size.height - currentBottomPadding -currentBottomRadius);
CGPoint topOrigin = CGPointZero;
if (distance == 0) {
    topOrigin = CGPointMake(floor(self.bounds.size.width / 2), bottomOrigin.y);
} else {
    topOrigin = CGPointMake(floor(self.bounds.size.width / 2), self.bounds.size.height + effectiveOffset + currentTopPadding + currentTopRadius);
    if (percentage == 0) {
        bottomOrigin.y -= (fabs(verticalShift) - kMaxDistance);
        triggered = YES;
    }
}

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.

4 participants