Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta http-equiv="Content-Style-Type" content="text/css">
  6. <title></title>
  7. <link rel="stylesheet" type="text/css" href="./fullPage/jquery.fullPage.css" />
  8. <script src="./jquery/1.11.1/jquery.min.js"></script>
  9. <script type="text/javascript" src="./fullPage/jquery.fullPage.js"></script>
  10. <style type="text/css">
  11. body, h1
  12. { margin: 0; }
  13.  
  14. #menu.fixed
  15. { position: fixed; top: 0; left: 0; }
  16.  
  17. #menu, #menuplaceholder
  18. {height:100px;}
  19.  
  20. #menu a.active{color:red}
  21.  
  22. #pageTitle { height: 100px;}
  23. </style>
  24. </head>
  25. <body>
  26. <div id="fullpage">
  27. <section data-anchor="section1" class="section" class="fixed">
  28. <h1 id="pageTitle">TAEA</h1>
  29. <div id="menu">
  30. <a data-menuanchor="section1" href="#section1">page 1</a>
  31. <a data-menuanchor="section2" href="#section2">page 2</a>
  32. <a data-menuanchor="section3" href="#section3">page 3</a>
  33. <a data-menuanchor="section4" href="#section4">page 4</a>
  34. </div
  35. <p>jkl</p>
  36. </section>
  37. <section data-anchor="section2" class="section">
  38. <h2>title</h2>
  39. <p>A</p>
  40. <p>B</p>
  41. <p>C</p>
  42. <p>D</p>
  43. <p>E</p>
  44. <p>F</p>
  45. <p>G</p>
  46. <p>H</p>
  47. <p>I</p>
  48. <p>J</p>
  49. <p>K</p>
  50. <p>L</p>
  51. <p>M</p>
  52. <p>N</p>
  53. <p>O</p>
  54. <p>P</p>
  55. <p>Q</p>
  56. <p>R</p>
  57. <p>S</p>
  58. <p>T</p>
  59. <p>U</p>
  60. <p>V</p>
  61. <p>W</p>
  62. <p>X</p>
  63. <p>Y</p>
  64. <p>Z</p>
  65. <p>A</p>
  66. <p>B</p>
  67. <p>C</p>
  68. <p>D</p>
  69. <p>E</p>
  70. <p>F</p>
  71. <p>G</p>
  72. <p>H</p>
  73. <p>I</p>
  74. <p>J</p>
  75. <p>K</p>
  76. <p>L</p>
  77. <p>M</p>
  78. <p>N</p>
  79. <p>O</p>
  80. <p>P</p>
  81. <p>Q</p>
  82. <p>R</p>
  83. <p>S</p>
  84. <p>T</p>
  85. <p>U</p>
  86. <p>V</p>
  87. <p>W</p>
  88. <p>X</p>
  89. <p>Y</p>
  90. <p>Z</p>
  91. </section>
  92. <section data-anchor="section3" class="section">
  93. <h2>title</h2>
  94. <p>content</p>
  95. </section>
  96. <section data-anchor="section4" class="section">
  97. <h2>title</h2>
  98. <p>content</p>
  99. </section>
  100. </div>
  101.  
  102. <script type="text/javascript">
  103. $(document).ready(function() {
  104. $('#fullpage').fullpage({
  105. sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke'],
  106. anchors:['section1','section2','section3','section4'],
  107. //verticalCentered: false,
  108. autoScrolling:false,
  109. menu:'#menu'
  110. });
  111. reset_scroll();
  112. });
  113. function onScroll() {
  114. var title_bottom = $('#pageTitle').offset().top + $('#pageTitle').outerHeight();
  115. var target_fixed = $(window).scrollTop() >= title_bottom;
  116. var is_fixed = $('#menu').parent()[0] == document.body && $('#menu').hasClass('fixed');
  117.  
  118. if ( target_fixed && !is_fixed )
  119. {
  120. console.log('change to fix');
  121. $('body').append($('#menu'));
  122. $('#pageTitle').after("<div id='menuplaceholder'>&nbsp;</div>");
  123. $('#menu').addClass('fixed');
  124. }
  125. else if ( !target_fixed && is_fixed )
  126. {
  127. console.log( 'change to normal');
  128. $('#menuplaceholder').detach();
  129. $('#pageTitle').after($('#menu'));
  130. $('#menu').removeClass('fixed');
  131. }
  132. else console.log('do nothing');
  133. }
  134. function reset_scroll()
  135. {
  136. $('#menuplaceholder').detach();
  137. $('#pageTitle').after($('#menu'));
  138. $('#menu').removeClass('fixed');
  139. onScroll();
  140. }
  141. $(window).on('scroll', onScroll);
  142. </script>
  143. </body>
  144. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement