andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 633 forks source link

Transparency effect glitches when scrolling slowly #325

Closed RemiGuyon closed 5 years ago

RemiGuyon commented 6 years ago

Describe the bug

The transparency effect on the elements of the navBar has glitches when dragging really slowly.

To Reproduce

Steps to reproduce the behavior:

  1. Open the demo
  2. Take the ScrollView sample for example
  3. Start dragging the view really slowly
  4. Observe the glitches on the transparency of the elements of the navBar

Expected behavior

The transparency effect should be really smooth as when you scroll the view at normal speed.

When looking at the code I noticed this in the updateNavbarAlpha() method:

navigationBar.subviews
      .filter(shouldHideView)
      .forEach { setAlphaOfSubviews(view: $0, alpha: alpha) }

It looked like to me that this was redundant with the rest of the method. So I tried to remove it and then everything worked as expected, no more glitches. I didn't notice any regression on the rest of the demo. Did I miss something about this piece of code?

andreamazz commented 6 years ago

Hey @RemiGuyon that code handles the subviews of the navigation bar, it works when there are custom views inside the navigation items. Not sure why this happens, I can see the glitch in the navigation title, but if I comment out everything but those lines, it's not affected, so that's odd 🤔

andreamazz commented 5 years ago

Should be fixed now, See #338