Advertisement
xpeed

Vehicle issue js

Jun 6th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(".vehicle-data").hide();
  2.     var activeVehicleData = $(".vehicle-nav .active a").attr("href");
  3.     $(activeVehicleData).show();
  4.  
  5.     $('.vehicle-nav-scroll').click(function () {
  6.         var topPos = 0;
  7.         var direction = $(this).data('direction');
  8.         var scrollHeight = $('.vehicle-nav li').height() + 1;
  9.         var navHeight = $('#vehicle-nav-container').height() + 1;
  10.         var actTopPos = $(".vehicle-nav").position().top;
  11.         var navChildHeight = $('#vehicle-nav-container').find('.vehicle-nav').height();
  12.         var x = -(navChildHeight - navHeight);
  13.        
  14.        
  15.        
  16.         // Scroll Down
  17.        if ((direction == 'down') && (actTopPos > x) && (-navHeight <= (actTopPos - (scrollHeight * 2)))) {
  18.             topPos = actTopPos - scrollHeight;
  19.             $(".vehicle-nav").css('top', topPos);
  20.             //alert(topPos+' '+ navChildHeight+' '+ x);
  21.         }
  22.  
  23.         // Scroll Up
  24.         if (direction == 'up' && 0 > actTopPos) {
  25.             topPos = actTopPos + scrollHeight;
  26.             $(".vehicle-nav").css('top', topPos);
  27.         }
  28.         return false;
  29.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement