index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. $(function(){
  2. $.fn.extend({
  3. //顶部浮动
  4. topNavPosition : function(){
  5. var _this = this;
  6. var _father = _this.parent();
  7. var _last = _this.find(".header-last-box");
  8. var _animate = true;
  9. $(window).scroll( function(){
  10. if($(window).scrollTop()>35 && _animate == true){
  11. _father.animate({
  12. height:"60px"
  13. });
  14. _this.css({
  15. "box-shadow":"1px 1px 30px #999"
  16. })
  17. _this.animate({
  18. top:"-35px"
  19. });
  20. _last.animate({
  21. height:"60px"
  22. });
  23. _animate = false;
  24. }
  25. if($(window).scrollTop() == 0){
  26. _father.animate({
  27. height:"115px"
  28. });
  29. _this.css({
  30. "box-shadow":"0px 0px 0px #999"
  31. })
  32. _this.animate({
  33. top:"0"
  34. },300);
  35. _last.animate({
  36. height:"80px"
  37. });
  38. _animate = true;
  39. }
  40. } )
  41. },
  42. //顶部下拉菜单
  43. topDropDownMwnu:function(){
  44. $(this).hover(function(){
  45. var _thisID = $(this).attr('id');
  46. $('.drop-down-menu').css({
  47. display:'block'
  48. });
  49. $('.'+_thisID).css({
  50. display:'block'
  51. }).siblings().css({
  52. display:'none'
  53. })
  54. },function(){
  55. $('.drop-down-menu').css({
  56. display:'none'
  57. });
  58. });
  59. $('.drop-down-menu').hover(function(){
  60. $('.drop-down-menu').css({
  61. display:'block'
  62. })
  63. },function(){
  64. $('.drop-down-menu').css({
  65. display:'none'
  66. })
  67. });
  68. }
  69. });
  70. function pageFun(){
  71. $('.header-nav-content-box').topNavPosition();
  72. $('.drop-down-but').topDropDownMwnu();
  73. }
  74. pageFun();
  75. })