ParallaxTableViewHeader icon indicating copy to clipboard operation
ParallaxTableViewHeader copied to clipboard

Extreme scrolling causes blur effect bug

Open ArthurU opened this issue 9 years ago • 2 comments

Hey,

What a brilliant parallax effect! Excellent job. I was only wondering if there was a way to fix this error:

What it is: screen shot 2015-10-18 at 09 44 22

What it should be: screen shot 2015-10-18 at 09 44 33

This occurs in the following circumstances:

  1. Scroll up to cover the header and reveal bottom cells
  2. Scroll very vigorously in one movement down again to reveal the header
  3. No side expansion with bounce or anything happens, it just increases in height and stays blurred.

A thing I have noticed is that the less the kParallaxDeltaFactor, the less the bug. I have it set a 1.0f. (The nav bar has nothing to do with it).

Any help would be greatly appreciated.

ArthurU avatar Oct 18 '15 08:10 ArthurU

Hi, I found a possible solution. I changed the layoutHeaderViewForScrollViewOffset method to:

- (void)layoutHeaderViewForScrollViewOffset:(CGPoint)offset
{
    CGRect frame = self.imageScrollView.frame;

    if (offset.y > 0)
    {
        frame.origin.y = MAX(offset.y *kParallaxDeltaFactor, 0);
        self.imageScrollView.frame = frame;
        self.bluredImageView.alpha =   1 / kDefaultHeaderFrame.size.height * offset.y * 2;
        self.clipsToBounds = YES;
    }
    else
    {
        CGFloat delta = 0.0f;
        CGRect rect = kDefaultHeaderFrame;
        delta = fabs(MIN(0.0f, offset.y));
        rect.origin.y -= delta;
        rect.size.height += delta;
        self.imageScrollView.frame = rect;
        self.clipsToBounds = NO;
        self.headerTitleLabel.alpha = 1 - (delta) * 1 / kMaxTitleAlphaOffset;
        self.bluredImageView.alpha =   1 / kDefaultHeaderFrame.size.height * offset.y * 2; <-- ADD THIS LINE
    }
}

As you see I added the alpha to be updated in the else statement, which seems to have solved the problem.

aborren avatar Dec 29 '15 04:12 aborren

Thanks @aborren . I encountered the same problem. Your solution works. The code should be updated accordingly.

sunlei053667 avatar Aug 18 '16 09:08 sunlei053667