index.js 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. $+(function(){
  2. var toolTop=$(".recommend").offset().top;
  3. toggleTool();
  4. function toggleTool(){
  5. if($(document).scrollTop() >= toolTop){
  6. $(".fixedtool").fadeIn();
  7. }else{
  8. $(".fixedtool").fadeOut();
  9. };
  10. }
  11. $(window).scroll(function(){
  12. toggleTool();
  13. });
  14. var flag=ture;
  15. $(".fixedtool li").click(function(){
  16. flag=false;
  17. var current=$(".floor .w").eq($(this).index()).offset().top;
  18. $("body,html").stop().animate({
  19. scrollTop:current
  20. },function(){
  21. flag = ture;
  22. });
  23. $(this).addClass("current").siblings().removeClass();
  24. });
  25. $(window).scroll(function(){
  26. toggleTool();
  27. if(flag){
  28. $(".floor .w").each (function(i, ele){
  29. if($(document.scrollTop >= $(ele).offset().top)){
  30. $(".fixedtool li").eq(i).addClass("current")
  31. .siblings().removeClass();
  32. }
  33. });
  34. }
  35. });
  36. });