2

I have an Angular website with a Bootstrap theme built primarily for iPhone users and since the IOS8 update I have found problems relating to scrolling. The site behaves fine until I scroll, once I have scrolled the links behave erratically eg if I press Button 2, the link from Button 1 will open. Also some CSS3 styles are not working eg :nth-child(even) I have searched for days trying to find a link between this behaviour and a scrolling bug but I can't find a fix anywhere. Unfortunately I cannot post the website link but it consists of a fixed Header and Footer, and a div set to overflow: auto; Any help is greatly appreciated :)

NB: I am using multiple accordions with in the scrollable element

Style for scrollable element

    .scrollable {
      overflow: auto;
      -webkit-overflow-scrolling: touch;
      position: absolute;
      top: 47px;
      bottom: 0px;
      left: 0px;
      right: 0px;
    }

Update: I have added an image from IOS simulator to illustrate the problem. I used Inspect Element to highlight the placement of the Anchor tag after scrolling. It's like Safari does not reset the position after scrolling.

enter image description here

Update: I think that this problem is related to the footer which is positioned using position: fixed; I haven't been able to confirm this yet but it looks like the root of the problem.

Clinton Green
  • 8,667
  • 15
  • 60
  • 101
  • I have experienced the same issue but cannot find a fix :( Mercury and Chrome seem to be working fine. I have had to resort to user agent sniffing and displaying a banner on top of my website asking my users to switch browsers until Apple releases a fix. –  Sep 30 '14 at 17:55
  • We've been having a similar problem. But, I haven't been able to narrow down a reproducible test case without the entire codebase. If you don't mind me asking, can you post your HTML + CSS you're using? – jsherer Sep 30 '14 at 19:10
  • @user1 Yes this is distressing, in the interim I've advised our users to change browsers. – Clinton Green Sep 30 '14 at 20:05
  • @jsherer My problem is definitely related to scrolling. Sorry I can't post the code. I'm running an Angular project so it uses lots of partials. Unfortunately I cant share a link either. – Clinton Green Sep 30 '14 at 20:08
  • Would you guys mind posting links to your websites it would help me with testing. Thanks – Clinton Green Sep 30 '14 at 20:09
  • Just a heads up, here is a website I found which is displaying the same behaviour, http://coenraets.org/apps/angular-directory/#/employees Try clicking on the names near the bottom of the list. You will see they open links from near the top of the list. – Clinton Green Sep 30 '14 at 22:05
  • I'm having slightly the opposite problem, the links don't work until I scroll a little on ios8, it's the fixed position on IOS 8. @user1 can you share how you sniff ios8? – Christina Oct 06 '14 at 19:00
  • http://www.macrumors.com/2014/09/23/ios-8-0-1-phone-keyboard-safari/ – Christina Oct 06 '14 at 19:07
  • @Christina - http://stackoverflow.com/questions/9038625/detect-if-device-is-ios –  Oct 06 '14 at 20:19
  • @user1 -- thanks! for my problem I made all the fixed absolute in the css and when user scrolls it turns in to positioned fixed, lucky for me this corrects the problem in IOS 8 and doesn't change any behavior elsewhere. What a crappy thing to contend with, though. It freaked me out. Worked smoothly in ios7 and under. – Christina Oct 06 '14 at 20:35
  • 1
    nth-of-type works -- what a pain in the ass – Christina Oct 06 '14 at 20:40
  • For anyone in the same predicament, Safari on IOS8 has an issue with transitions. If you remove those all should be working. – Clinton Green Oct 09 '14 at 02:59

3 Answers3

4

We have a similar issue. The result of the analysis based on reproducible observations: The vertical Position of the touch is not passed correctly to Safari, i.e. if you touch the screen at x/y position 100/200, the Position 100/300 is passed to the browser. This Delta becomes bigger and bigger the more often you touch the Screen. You can observe this best if you have a series of elements in different rows. At the beginning you click on row 1 and row 1 is activated. A bit later you click on row 2 and row 1 is activated, and then row 3, row 4 till you touch the most bottom row, and then the y coordinate passed is even above the 0 position. Before looking at the user workaround for our site, please note that we have the following event handler for rotation change:

function doOnOrientationChange()
{
  switch(window.orientation) 
  {
    case -90:
    case 90:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.9,width=device-width');
      break; 
    default:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.75,width=device-width');
      break; 
  }
}

The Workaround for the user:

  • Zoom in and out again. This solves the issue until the page is changed or tab is closed
  • Alternatively: change the rotation to Portrait and back

If I add user-scalable=no to the view-port setting, the issue does not appear at all:

function doOnOrientationChange()
{
  switch(window.orientation) 
  {
    case -90:
    case 90:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.9,width=device-width,user-scalable=no');
      break; 
    default:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.75,width=device-width,user-scalable=no');
      break; 
  }
}

But this is not a solution for us. Actually we had added this setting after iOS7 was released. It was just a Workaround for a iOS7 bug. Later we found another workaround and we could remove this restriction. Now after releasing iOS8, I have a Kind of dejavú, since we could add the same setting, this time as a workaround for a bug in iOS8. But fortunately there is another workaround which works fine for us. Directly after the page is loaded, the following is launched which simulates a zoom out and in by the user:

function ios8BugFixPart1() {
  // zoom out
  switch(window.orientation) 
  {
    case -90:
    case 90:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.8,width=device-width');
      break; 
    default:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.70,width=device-width');
      break; 
  }
 setTimeout(ios8BugFixPart2, 200);
}
function ios8BugFixPart2() {
  // zoom in
  switch(window.orientation) 
  {
    case -90:
    case 90:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.9,width=device-width');
      break; 
    default:
  viewport = document.querySelector("meta[name=viewport]");
  viewport.setAttribute('content', 'initial-scale=0.75,width=device-width');
      break; 
  }
}
setTimeout(ios8BugFixPart1, 1000);

I hope this will help some of you as well.

PS: is there any possiblity to prevent the Cupertino guys from introducing new OS Versions, even if the changes are so small as it is the case this time?

  • I'm going to try this! Thank you so much for sharing. I am really tired of bug smushing. – Christina Oct 14 '14 at 02:51
  • It works! I am so happy! Thanks a thousand times over! – Christina Oct 14 '14 at 03:00
  • Is there anyway it can go to the top? Right now it loads the page about 100px down from the top. – Christina Oct 14 '14 at 03:13
  • I assume what you are describing is a result of zooming in&out. My page is on start-up smaller than the display height. So I don't have this effect. – user3250994 Oct 14 '14 at 10:18
  • I think you need to use something like window.scrollTo – user3250994 Oct 14 '14 at 10:24
  • Tried that but whether I put it inside or outside the function it didn't work. I figured out another way. – Christina Oct 14 '14 at 14:17
  • I cannot comment on your other solution because I'm still new and don't have the minimum reputation value of 50. Unfortunately your other, more compact solution does not work for me although if I simulate it manually through the user Interface it solves the issue. I think it depends on my page's structure. It is a pity since my own solution has the drawback that the user sees the short zoom out and in at the beginning. However, the best solution would be if Apple fixes its bugs. – user3250994 Oct 14 '14 at 20:04
  • Yes, that would be the best solution. Very, very annoying to have this when it works great in IOS 7 and android, chrome, opera etc., but to not work in the "flagship" of graphics brand is freaking nuts! – Christina Oct 14 '14 at 20:39
2

This is what ultimately worked for me, strange as it is:

$(window).load(function() {
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID) {

    setTimeout(function(){
        window.scrollTo(1, 1);
    }, 100);

    // http://davidwalsh.name/hide-address-bar
}

}); 
Christina
  • 32,538
  • 17
  • 76
  • 118
1

A developer at work managed to solve this issue by removing transitions between pages. See the code he commented out below. It was found in controllers.js. Hopefully this example will help you find the transition code in your project.

$scope.slide = '';
$rootScope.back = function() {

//$scope.slide = 'slide-right';
 $window.history.back();
}
$rootScope.go = function(path){
//$scope.navLeft = false;
//$scope.navRight = false;
//$scope.slide = 'slide-left';
$location.url(path);
}
Clinton Green
  • 8,667
  • 15
  • 60
  • 101
  • Voted up but it didn't work for me and neither did my solution ultimately. My site only works in IOS8 if you touch the screen and scroll just a little then it works, but when you load it doesn't work and when you re-load it doesn't work. – Christina Oct 11 '14 at 21:42
  • My issues was the site started acting weirdly when you scrolled. Man IOS8 is throwing some curveballs. Have you got a link I can check out? – Clinton Green Oct 13 '14 at 19:35
  • I'm thinking it will resolve with the newest IOS update so I'm not fixing unless it isn't fixed. Once I get it together, I'll send a link. Are you updated to the latest 8.0.2 (is that the one with the fix?) – Christina Oct 13 '14 at 19:43
  • 1
    Yes I thought 8.0.2 might fix it but it was still buggy :( – Clinton Green Oct 13 '14 at 23:53