Skip to content

Affix doesn't update in iOS UIWebview #16202

Closed

Description

@mhemesath

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.

    this.$target = $(this.options.target)
      .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
      .on('touchmove.bs.affix.data-api', $.proxy(this.checkPosition, this))
      .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))

Activity

  1. changed the title [-]Affix doesn't update in uiwebview[/-] [+]Affix doesn't update in iOS UIWebview[/+] on Apr 1, 2015
  2. added
    js
    on Apr 1, 2015
  3. cvrebert commented on Apr 1, 2015

    @cvrebert
    Collaborator

    What version of iOS are you using?

  4. mhemesath commented on Apr 1, 2015

    @mhemesath
    Author

    iOS 8.2. You can reproduce the issue in Chrome for iOS

  5. mhemesath commented on Apr 2, 2015

    @mhemesath
    Author

    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.

  6. cvrebert commented on Apr 4, 2015

    @cvrebert
    Collaborator

    Does WKWebView suffer from the same problem?

  7. mhemesath commented on Apr 6, 2015

    @mhemesath
    Author

    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.

  8. added
    browser-bug
    on Apr 6, 2015
  9. cvrebert commented on Apr 21, 2015

    @cvrebert
    Collaborator

    @mhemesath Have you gotten a chance to try the other workaround I linked to above?

  10. mhemesath commented on Apr 22, 2015

    @mhemesath
    Author

    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).

  11. cvrebert commented on Apr 22, 2015

    @cvrebert
    Collaborator

    Can you post what the UIWebview uses as its user agent string?

    For comparison:

    • iOS 8.3 Safari
      • 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.4
    • OS X Safari 8.0.5
      • Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.17 (KHTML, like Gecko) Version/8.0.5 Safari/600.5.17
  12. mhemesath commented on Apr 22, 2015

    @mhemesath
    Author

    Mozilla/5.0 (iPhone; CPU iPhone OS 10_10_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508

  13. cvrebert commented on May 3, 2015

    @cvrebert
    Collaborator

    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?

  14. fat commented on May 4, 2015

    @fat
    Member

    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.

  15. shasharoman commented on Mar 15, 2017

    @shasharoman

    try use touchstart event on element and do nothing, but scroll events aren't fired when fingers leave the screen.

  16. cvrebert commented on Mar 15, 2017

    @cvrebert
    Collaborator
  17. locked and limited conversation to collaborators on Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    browser-bugjs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions