Permalink
Browse files

Update DVParallaxView.m

Using status bar orientation instead of device orientation for better results.
  • Loading branch information...
drewmca committed Feb 12, 2014
1 parent e4621f7 commit ec721e08d933a3588c4196ecb24e3d661fa0ceb5
Showing with 8 additions and 6 deletions.
  1. +8 −6 DVParallaxView/DVParallaxView.m
@@ -157,15 +157,17 @@ -(void)addSubview:(UIView *)view {
#pragma mark - Gyroscope to offset
- (CGPoint)contentOffsetWithRotationRate:(CMRotationRate)rotationRate {
- double xOffset = (fabs(rotationRate.y) > DV_ROTATION_THRESHOLD)?rotationRate.y*DV_ROTATION_MULTIPLIER:0.f;
- double yOffset = (fabs(rotationRate.x) > DV_ROTATION_THRESHOLD)?rotationRate.x*DV_ROTATION_MULTIPLIER:0.f;
- CGPoint newOffset;
- if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])){
- newOffset = CGPointMake(self.contentOffset.x + yOffset, self.contentOffset.y + xOffset);
+ double xOffset;
+ double yOffset;
+ if (UIDeviceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])){
+ xOffset = (fabs(rotationRate.x) > DV_ROTATION_THRESHOLD)?rotationRate.x*DV_ROTATION_MULTIPLIER:0.f;
+ yOffset = (fabs(rotationRate.y) > DV_ROTATION_THRESHOLD)?rotationRate.y*DV_ROTATION_MULTIPLIER:0.f;
}
else{
- newOffset = CGPointMake(self.contentOffset.x + xOffset, self.contentOffset.y + yOffset);
+ xOffset = (fabs(rotationRate.y) > DV_ROTATION_THRESHOLD)?rotationRate.y*DV_ROTATION_MULTIPLIER:0.f;
+ yOffset = (fabs(rotationRate.x) > DV_ROTATION_THRESHOLD)?rotationRate.x*DV_ROTATION_MULTIPLIER:0.f;
}
+ CGPoint newOffset = CGPointMake(self.contentOffset.x + xOffset, self.contentOffset.y + yOffset);
return newOffset;
}

0 comments on commit ec721e0

Please sign in to comment.