special.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(function() {
  2. var box = $('.list-wrap');
  3. box.each(function(index) {
  4. //Todo => 高度大于108显示箭头
  5. if($(this).height() > 108){
  6. var flag = true;
  7. var target = $(this);
  8. var chil = target.height('108px').siblings('.jiantou');
  9. chil.fadeOut(function(){$(this).fadeIn().css('display','block')});
  10. chil.click(function(){
  11. if(flag){
  12. target.fadeOut(function(){
  13. $(this).height('100%').fadeIn();
  14. });
  15. $(this).html('收起')
  16. flag = false;
  17. }else{
  18. target.fadeOut(function(){
  19. $(this).height('108px').fadeIn();
  20. });
  21. flag = true;
  22. $(this).html('加载更多')
  23. }
  24. });
  25. }
  26. })
  27. var right_box = $('.right-box.jlr');
  28. var jlr_box = $('.right-box.jlr .jlr-box');
  29. var right_btn = $('.right-box.jlr .jlr-btn i');
  30. add(jlr_box,right_btn,0,3000);
  31. function add(ele,btn,count=0,special) {
  32. ele.parent().data('timer', setInterval(function(){
  33. count ++;
  34. if(count >= ele.length){
  35. count = 0;
  36. }
  37. box_loop(ele, count);
  38. btn_loop(btn, count);
  39. },special));
  40. }
  41. function box_loop(ele,count=0){
  42. ele.eq(count).addClass('active').siblings().removeClass('active');
  43. }
  44. function btn_loop(ele,count=0){
  45. ele.eq(count).addClass('active').siblings().removeClass('active');
  46. }
  47. $(right_btn).mouseover(function() {
  48. console.log(right_box.data('timer'));
  49. clearInterval(right_box.data('timer'));
  50. var target_index = $(this).index();
  51. jlr_box.eq(target_index).addClass('active').siblings().removeClass('active');
  52. right_btn.eq(target_index).addClass('active').siblings().removeClass('active');
  53. }).mouseout(function(event) {
  54. var target_index = $(this).index();
  55. add(jlr_box,right_btn,target_index,3000);
  56. });
  57. var slide = $('#slide-scroll');
  58. var slide_ul = $('#slide-scroll').find('ul');
  59. slided(slide_ul,0,100);
  60. $(slide_ul).mouseenter(function() {
  61. clearInterval($(this).data('timer'));
  62. }).mouseleave(function() {
  63. var target_num = parseInt($(this).css('marginTop'));
  64. slided(slide_ul,target_num,100);
  65. });
  66. function slided(ele,num=1,special) {
  67. ele.data('timer', setInterval(function(){
  68. num --;
  69. if(num === -36){
  70. num = 0;
  71. var $li = $(ele).find('li:lt(2)').remove();
  72. ele.append($li);
  73. }
  74. ele.css('marginTop',num);
  75. },special));
  76. }
  77. });