index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. $(function(){
  2. //轮播图
  3. var swiper = new Swiper('.swiper-container', {
  4. loop : true,
  5. centeredSlides: true,
  6. autoplay: {
  7. delay: 2500,
  8. disableOnInteraction: false,
  9. },
  10. pagination: {
  11. el: '.swiper-pagination',
  12. clickable: true,
  13. },
  14. });
  15. //点击榜tab
  16. $('.i_m_tit_tab a').click(function(){
  17. var $this=$(this);
  18. var nIndex=$this.index();
  19. var smoreurl=$this.attr('smoreurl');
  20. $this.addClass('hover').siblings('a').removeClass('hover');
  21. $('.i_images_scroll_list ul').eq(nIndex).addClass('i_images_scroll_ul_hover').siblings('ul').removeClass('i_images_scroll_ul_hover');
  22. $('.i_m_tit_tab_more').attr('href',smoreurl);
  23. });
  24. //图片懒加载
  25. $('img').picLazyLoad({
  26. effect : "fadeIn"
  27. });
  28. $(window).scrollTop($(window).scrollTop()+1);
  29. $(window).scrollTop($(window).scrollTop()-1);
  30. scroll(function(direction) {
  31. if(direction=='down'){
  32. $('body').removeClass('fixednav');
  33. }else{
  34. if(afterScrollTop>100) {
  35. $('body').addClass('fixednav');
  36. }else{
  37. $('body').removeClass('fixednav');
  38. }
  39. }
  40. });
  41. $('.special_item').each(function(index, item){
  42. var data = {
  43. from:$(item).attr('data-from'),
  44. special_id:$(item).attr('data-special_id'),
  45. };
  46. cpslog([702, data]);
  47. });
  48. });
  49. //滚动滚轮
  50. var afterScrollTop=0;
  51. function scroll( fn ) {
  52. var beforeScrollTop = $(window).scrollTop(),
  53. fn = fn || function() {};
  54. $(window).scroll(function() {
  55. afterScrollTop = $(window).scrollTop();
  56. var delta = afterScrollTop - beforeScrollTop;
  57. if( delta === 0 ) return false;
  58. fn( delta > 0 ? "down" : "up" );
  59. beforeScrollTop = afterScrollTop;
  60. });
  61. }