Guest User

Untitled

a guest
Oct 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. .image_holder {
  2. display: block;
  3. height: 100%;
  4. }
  5.  
  6. .section{
  7. position: relative;
  8. height: 80vh;
  9. background: rgba(255, 226, 57, 0.0);
  10. overflow-y: scroll;
  11. margin: 0 auto;
  12. border: #000000 solid thin;
  13. }
  14.  
  15. <div class="page_scroller">
  16. <ul >
  17. <li class="list-unstyled col-lg-6 bg-primary"><a href="#" id="prev" class="arrow-up prev">Up</a></li>
  18. <li class="list-unstyled col-lg-6 bg-primary"><a href="#" id="next" class="arrow-down next">Down</a></li>
  19. </ul>
  20. </div>
  21.  
  22. <div class="section" >
  23.  
  24. <div id="highlight-1" class="current image_holder">A</div>
  25. <div id="highlight-2" class="image_holder ">B</div>
  26. <div id="highlight-3" class="image_holder ">C</div>
  27. <div id="highlight-4" class="image_holder ">D</div>
  28.  
  29. </div>
  30.  
  31. var scrollTo = function(element) {
  32. console.log(element);
  33. $('.section').animate({
  34. scrollTop: element.offset().top
  35. }, 500);
  36. }
  37.  
  38. $('.next').click(function(event) {
  39. event.preventDefault();
  40. var $current = $('.section > .image_holder.current');
  41. var $next = $current.next().first();
  42. if ($next.length!=0) {
  43. $current.removeClass('current')
  44. $next.addClass('current');
  45. scrollTo($next);
  46. }
  47. });
  48.  
  49. $('.prev').click(function(event) {
  50. event.preventDefault();
  51. var $current = $('.section > .image_holder.current');
  52. var $prev = $current.prev().first();
  53. if ($prev.length!=0) {
  54. $current.removeClass('current')
  55. $prev.addClass('current');
  56. scrollTo($prev);
  57. }
  58. });
  59.  
  60. $('.section').animate({
  61. scrollTop: element.offset().top
  62. }, 500);
  63.  
  64. $('.section').animate({
  65. scrollTop: element.position().top
  66. }, 500);
Add Comment
Please, Sign In to add comment