You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In UIWebview scroll events aren't fired. This has the effect of making affix look buggy as its position isnd't updated until after scroll is done. To mitigate the effects of this, we could add a touchmove event listener to update the affix position when the user is scrolling via moving their finger.
That doesn't solve the issue. The view can scroll, it just doesn't fire any scroll events while it is going. This causes the affix to not "stick" until after scroll ends.
No, I haven't tested it but from what I've read the WKWebview is similar to the native Safari in iOS 8.X and will throw scroll events while scrolling. This is only a a problem for UIWebview in iOS.
Sorry, that didn't seem to work either. We are getting scroll events, just not until after scroll is over. I can try to throw together a test page that should be reproducible with Chrome on iOS (which uses webview I think).
So, my research didn't turn up any way to differentiate between UIWebView vs. WKWebView via JS.
UIWebView can be distinguished from Safari by looking for the "Version/" token in the user agent, which is present in Safari but absent in both types of webview.
@fat What are your thoughts here, given the possible performance penalty of a touch event handler?
I'm inclined not to add this directly into the plugin. Mobile scroll stuff has always been kinda jank and I'm a bit worried about potential sideeffects of adding the touchmove for all cases.
Also, i feel better about passing on this because it seems like there are a couple of straightforward ways to get this behavior in your app – you could subclass Affix pretty simply or just write a quick little script to pipe touchevents through for your specific target/instance.
Activity
[-]Affix doesn't update in uiwebview[/-][+]Affix doesn't update in iOS UIWebview[/+]cvrebert commentedon Apr 1, 2015
What version of iOS are you using?
mhemesath commentedon Apr 1, 2015
iOS 8.2. You can reproduce the issue in Chrome for iOS
cvrebert commentedon Apr 1, 2015
Does http://stackoverflow.com/a/10880812 not work?
mhemesath commentedon Apr 2, 2015
That doesn't solve the issue. The view can scroll, it just doesn't fire any scroll events while it is going. This causes the affix to not "stick" until after scroll ends.
cvrebert commentedon Apr 4, 2015
Does WKWebView suffer from the same problem?
mhemesath commentedon Apr 6, 2015
No, I haven't tested it but from what I've read the WKWebview is similar to the native Safari in iOS 8.X and will throw scroll events while scrolling. This is only a a problem for UIWebview in iOS.
cvrebert commentedon Apr 6, 2015
Okay, have you tried https://poschel.wordpress.com/2013/08/29/uiwebview-javascript-scroll-events-in-ios-7/ ?
cvrebert commentedon Apr 21, 2015
@mhemesath Have you gotten a chance to try the other workaround I linked to above?
mhemesath commentedon Apr 22, 2015
Sorry, that didn't seem to work either. We are getting scroll events, just not until after scroll is over. I can try to throw together a test page that should be reproducible with Chrome on iOS (which uses webview I think).
cvrebert commentedon Apr 22, 2015
Can you post what the UIWebview uses as its user agent string?
For comparison:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.17 (KHTML, like Gecko) Version/8.0.5 Safari/600.5.17mhemesath commentedon Apr 22, 2015
Mozilla/5.0 (iPhone; CPU iPhone OS 10_10_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508
cvrebert commentedon May 3, 2015
So, my research didn't turn up any way to differentiate between UIWebView vs. WKWebView via JS.
UIWebView can be distinguished from Safari by looking for the "Version/" token in the user agent, which is present in Safari but absent in both types of webview.
@fat What are your thoughts here, given the possible performance penalty of a touch event handler?
fat commentedon May 4, 2015
I'm inclined not to add this directly into the plugin. Mobile scroll stuff has always been kinda jank and I'm a bit worried about potential sideeffects of adding the touchmove for all cases.
Also, i feel better about passing on this because it seems like there are a couple of straightforward ways to get this behavior in your app – you could subclass Affix pretty simply or just write a quick little script to pipe touchevents through for your specific target/instance.
cvrebert commentedon May 29, 2015
Added a note about this to MDN: https://developer.mozilla.org/en-US/docs/Web/Events/scroll#iOS_UIWebView
shasharoman commentedon Mar 15, 2017
try use touchstart event on element and do nothing, but scroll events aren't fired when fingers leave the screen.
cvrebert commentedon Mar 15, 2017
Affix is no longer officially supported; see https://v4-alpha.getbootstrap.com/migration/#components