Guest User

ios5 css scroll bug

a guest
Nov 23rd, 2011
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title></title>
  6.  
  7. <meta charset="utf-8">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
  9. <meta name="apple-mobile-web-app-capable" content="yes" />
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  11.  
  12. <!-- ALL CSS STYLES -->
  13. <style>
  14.  
  15. html {
  16. background: black;
  17. color: #FFF;
  18. font: normal 1.6em Helvetica, Arial, sans-serif;
  19. }
  20.  
  21. body,ul,li {
  22. padding: 0;
  23. margin: 0;
  24. border: 0;
  25. }
  26.  
  27. body {
  28. -webkit-user-select: none;
  29. -webkit-text-size-adjust: none;
  30. -webkit-tap-highlight-color: rgba(0,0,0,0);
  31. }
  32.  
  33. .viewPanel {
  34. position: absolute;
  35. left: 0px;
  36. right: 0px;
  37. top: 0px;
  38. bottom: 0px;
  39. overflow: hidden;
  40. }
  41.  
  42. .scrollerWrapper {
  43. overflow: auto;
  44. width: 100%;
  45. }
  46.  
  47. .scrollerInnerWrapper {
  48. overflow: scroll;
  49. -webkit-overflow-scrolling: touch;
  50. }
  51.  
  52. .horizontalScrollable {
  53. height: 100px;
  54. }
  55.  
  56. .scrollersContainer {
  57. position: absolute;
  58. left: 0px;
  59. right: 0px;
  60. top: 90px;
  61. bottom: 60px;
  62. }
  63.  
  64. .tab-bar {
  65. position:absolute;
  66. bottom:0px;
  67. left:0px;
  68. right:0px;
  69. height:64px;
  70. }
  71.  
  72. .tab-button {
  73. float: left;
  74. width: 120px;
  75. height: 64px;
  76. background-size:64px 64px;
  77. background-repeat:no-repeat;
  78. }
  79.  
  80. .dummy-wrapper {
  81. font-size:12px;
  82. width: 104px;
  83. height: 98px;
  84. float: left;
  85. margin: 0 0 0 2px;
  86. background-size: 104px 98px;
  87. background-repeat: no-repeat;
  88. }
  89.  
  90. .dummy-wrapper:active {
  91. -webkit-box-shadow: inset 0 0 15px 0.5em white;
  92. }
  93.  
  94.  
  95. </style>
  96.  
  97. <!-- LIBRARIES (plain)-->
  98.  
  99. <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
  100.  
  101. <script type="text/javascript">
  102.  
  103.  
  104.  
  105.  
  106. function onLoad(){
  107. document.addEventListener("deviceready", onDeviceReady, false);
  108. }
  109.  
  110. function onDeviceReady() {
  111. console.log('onDeviceReady');
  112.  
  113. // global error handling...
  114. window.onerror = function(err) {
  115. console.error('ERROR: '+err.message);
  116. };
  117.  
  118. // monitor touch and gesture events, (also seems to help the active state bug caused by CSS scroll.)
  119. var events = ["gesturestart", "gesturechange", "gestureend", "mousemove", "mousedown", "mouseup", "mouseover", "mouseout", "touchcancel", "touchend", "touchmove", "touchstart"];
  120. for(var i=0; i<events.length; i++){
  121. var event = events[i];
  122. window.addEventListener(event,function(){console.log('event='+event);},true);
  123. }
  124.  
  125. makeTabs();
  126.  
  127. // start the application
  128. goScreen1();
  129. }
  130.  
  131. function makeTabs(){
  132. document.getElementsByTagName('body')[0].innerHTML = '<div id="viewPanel" class="view-panel"></div><div id="tabBar" class="tab-bar"><div id="screen1-button" class="tab-button">[screen 1]</div><div id="screen2-button" class="tab-button">[screen 2]</div></div>';
  133. document.getElementById('screen1-button').addEventListener('touchstart', function(){
  134. goScreen1();
  135. }, false);
  136. document.getElementById('screen2-button').addEventListener('touchstart', function(){
  137. goScreen2();
  138. }, false);
  139. }
  140.  
  141. function goScreen1(){
  142.  
  143. document.getElementById('viewPanel').innerHTML = '';
  144. document.getElementById('viewPanel').innerHTML = '<div>Scroll the divs below... then go to screen 2.</div><div class="scrollersContainer"><div class="scrollerWrapper"><div class="scrollerInnerWrapper"><div class="horizontalScrollable" id="featuredScroll" style="width: 856px; "><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div></div></div></div><div class="scrollerWrapper"><div class="scrollerInnerWrapper"><div class="horizontalScrollable" id="brandsScroll" style="width: 856px; "><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div></div></div></div><div class="scrollerWrapper"><div class="scrollerInnerWrapper"><div class="horizontalScrollable" id="streamScroll" style="width: 856px; "><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div><div class="dummy-wrapper" >Text in a div</div></div></div></div></div>';
  145.  
  146. };
  147.  
  148. function goScreen2(){
  149.  
  150. document.getElementById('viewPanel').innerHTML = '';
  151. document.getElementById('viewPanel').innerHTML = '<input type="button" id="back-button" class="button" value="CLICK THIS BUTTON"/><div>The first time you visit this screen, the click event is never fired so the button is not clickable... Now go back to screen1 and the scrollers are broken...</div>';
  152. document.getElementById('back-button').addEventListener('click', function(){
  153. alert('BUTTON CLICK!');
  154. }, false);
  155. };
  156.  
  157. </script>
  158. </head>
  159. <body onload="onLoad()">
  160. </body>
  161. </html>
  162.  
  163.  
Advertisement
Add Comment
Please, Sign In to add comment