New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form elements can lose click hit area in position: fixed containers #1
Comments
I found something that seems similar - my touch events were no longer triggered on buttons in a fixed position header after I manually scrolled. Here's my touch code: For some reason adding a touchstart event to body fixed it: I don't understand why, unfortunately. |
Thanks, @pamelafox. Think that warrants a separate issue? @Wilto filed issue #3 on Android fixed position bugs, which have some iOS5 overlap too I think. |
@pamelafox: I would be frightened for you if you could fully understand Android’s @scottjehl: I’ll go in and split those up into separate properly-formatted issues later on today, methinks. |
Found a great fix for iOS. Simply add a div triggering scrolling to the end of the document (a height of 101% should work) then create a setTimeout with a delay of 0 to remove the div. This will cause iOS to recalculate the hit position of fixed area elements |
+1 to the strange fix by pamelafox. Was facing the same issue on manual scroll and have been racking my brains for quite a while. You just saved my life. |
I have a fixed position button with a click handler. I tried Pamela's solution but it didn't work in this case. |
I was able to work around this basically by doing the opposite of what kentongray did. We have a fixed header with buttons, and are showing/hiding divs. Whenever we show/hide divs, we call ScrollView to reset our window to the top position. If we did this while the screen was scrolled down (not already in top position), the buttons would stop responding until a manual scroll was performed. But if the window was at the top position when we called ScrollView, the bug didn't happen. We got around this by changing the order of events. We hide the main div we're about to take away, then we call ScrollView, THEN we show our new main div. When performed in this order, our buttons always continue working. It seems that hiding the main view shortens the view into the size of the window, which somehow prevents the bug. Hope that helps someone. |
@jaredthigpen it definitely helped me, cheers! I had very similar symptoms (the fixed div not responding to clicks, or jumping to the middle of the page), and like you it didn't happen if the page was already scrolled to the top - and get back to normal after a manual scroll. It's a single page web-app, so the code looked like:
After spending hours trying everything else (101% height divs, empty handlers...), your suggestion worked like a charm:
I wish I had seen your post or thought about it earlier! |
I too have a button that is fixed at the bottom and I couldn't get position:fixed; to stay at the bottom on Android 2.x until I added the following: $('#docked-nav').css('-webkit-transition', '-webkit-transform 0.5s').css('-webkit-transform', 'translateX(0px)'); Don't ask me why it works, it's a lucky guess :) The button doesn't respond to tap once scrolled though. @pamelafox fix did not work for me. |
@rprieto Where did you put that code? $('body').scroll? |
@sebumd For me the problem happened when scrolling while "changing page". Since it's a single-page web app, changing page is really custom code that changes the visibility of certain DIVs:
So now it looks like:
I hope it's a bit clearer. |
I faced the same problem: I had a fixed positioned header having a back button. $(document.bind('silentscroll', function(e,data){ )}; |
Here is a way around the bug without a hack. Instead of having the mobile site scroll in the body, disable body scrolling, set height to 100%, and then use a container div for the scrolling instead. This way the fixed elements are outside of the scrollable area, making them immune to this bug. I tried all the hack solutions out there, but all of them had this bug. Only after separating the fixed elements and the scroll area was the issue fixed. Chris |
Platforms:
How to reproduce:
window.scrollTo
orscrollBy
Note: double-tapping the control does work in iOS5
Reduced Example:
http://jsbin.com/iredok
Bug Tracker ticket(s):
Workarounds:
None known.
The text was updated successfully, but these errors were encountered: