0

(Website link has been removed by the author)

The situation is there are two chevron anchors (<a>) on the page. (They were added into the DOM via javascript) One is "Previous" and another is "Next". By clicking on the "Next" anchor, the toNextSection() function will be triggered and the page will scroll to the next section, and vice versa.

That works on all desktop browsers, but is odd on iPad.

Originally, the two chevrons were bound with the "click" event. I then tried changing the code to the following in order to fix the iPad issue, but the issue remains. So I guess the problem is not the event type.

var clickEvent = navigator.platform.match(/iPad/i) ? 'touchstart' : 'click';
$('#sectionnav .prev a').on(clickEvent, function() { toPrevSection() });
$('#sectionnav .next a').on(clickEvent, function() { toNextSection() });



There are some information I have gathered so far about the iPad issue:
  • The first time tapping the "Next" chevron, the page scrolls to the next section successfully. But after that, you can no longer tap either of the chevrons again. Tapping them a second time does nothing.

  • I had tried replacing all contents of the toPrevSection() function with a single line: alert('Test');, and then tapping the "Previous" chevron can always show alert box successfully. But as mentioned above, after tapping the "Next" chevron to scroll the page to the next section, tapping the "Previous" chevron can no longer show any alert box.

  • I had tried setInterval('toNextSection()', 10000); or setInterval(function() { $('#sectionnav .next a').trigger('touchstart') }, 10000); and the page can successfully scroll to the end autometically.

  • If you manually slide the page a bit forward before tapping the "Next" chevrons, then tapping the "Next" chevrons can no longer scroll the page.

NEW:

  • I also tried binding the click event to other elements such as the logo or images in the footer. And the issue is the same. Tapping at the first time works and the second time does nothing.

  • After tapping the "Next" chevron (or whatever is bound with the click event) and the page scrolls to the next section, all hyperlinks and form button on the page no longer work (tapping on them does nothing).

  • When the page is set to auto scrolling (the setInterval mentioned above), tapping the "Next" chevrons before the page starts auto scrolling still works (and the auto scrolling works, too). But after the page starts auto scrolling, all hyperlinks and form button on the page no longer work (tapping on them does nothing).



Any advise would be greatly appreciated. Thanks!
Ian Y.
  • 2,293
  • 6
  • 39
  • 55

2 Answers2

1

Did you check if other elements, Since the screen is changing that are placed above the buttons and prevents them from getting the touches?
You can mabey Change the buttons z-index to place them "higher" but that will work only if their position property is absulote or relative etc.

OK

Try maybe looking in this page on point number 5, it is about touch events on iOS safari. https://developer.apple.com/library/safari/#technotes/tn2010/tn2262/_index.html

shannoga
  • 19,649
  • 20
  • 104
  • 169
  • Thanks. However, I tried many approaches to ensure the chevrons is on the very top, and tried shrink the height of content to 20px, but the issue remains. So it's not because anything covers the chevrons. Btw, I had added two new information with regard to the issue. Please check it. – Ian Y. Jul 15 '12 at 01:25
  • Hi, I an trying to figure it out and I found some info on apple docs, edited my answer. – shannoga Jul 15 '12 at 04:33
  • Thank you. I can feel your genuineness. Yet the apple page couldn't offer much help. I adjusted the -webkit-user-select it suggests, and the issue remains. – Ian Y. Jul 15 '12 at 09:51
  • Just frustrated I can not figure it out :). – shannoga Jul 15 '12 at 10:09
1

Hard to debug, as it really only happens on iOS devices (and simulators). I am almost sure that this has nothing to do with your JavaScript but only with page scrolling and element positioning and how it is handled on iOS. This might even be a bug in iOS Safari (see below).

It seems that most of the links (next, previous,Twitter, Facebook etc.) only work when your page is in its exact original position (you mentioned this). For example, you can click next, then scroll back to the beginning and click next again. So it seems that the buttons are shown as they should, but the clickable areas are in its original place, outside the visible area.

Another observation: as you said, none of your links works after you clicked next. However, when you reload the page after scrolling to the right, next and previous still have no effect (the page is automatically scrolled to where it was before), but all the other links work.

I found another question that mentions this, providing a simple example page that still shows this odd bahaviour in iOS 5.1 simulator. The proposed solution (16 upvotes right now) is to set position:relative, scroll, and then set position:fixed again (which is by the way only supported from iOS5, but I guess that's what you are using). In contrast to that example I was not able to find the clickable area somewhere on your page though.

Besides trying that workaround, I would suggest the following to get to the bottom of this:

  • Try to dumb your style down until the positioning works, you have position:absolute and position:fixed on a lot of elements.

  • Unlink the scroll event handler, besides being a potential cause for your problems, this is really getting in the way of using the site. At best, you completely separate the content positioning and vertical scrolling. I don't know for sure what this means for the parallax effect.

Hope this helps and good luck with fixing this issue.

EDIT: There is a bug reported (status duplicate – I did not find the original). Also, the fix described in another answer worked for me.

Community
  • 1
  • 1
Wolfram
  • 8,044
  • 3
  • 45
  • 66
  • Thank you. I tried all methods mentioned in the another question and still couldn't get rid of the iOS bug. That's okay. At least I had learned that it is iOS's problem. – Ian Y. Jul 15 '12 at 12:21
  • Yep, seems like it. You might want to provide a more robust mobile version of that site without the scrolling effect. While parallax scrolling [is possible](http://www.nike.com/jumpman23/aj2012/) on iOS, other pages fall back to a static version on iOS (examples: [1](http://www.ok-studios.de/home/), [2](http://community.saucony.com/kinvara3/)). There seem to be some issues like the one you are experiencing right now. – Wolfram Jul 15 '12 at 12:37