kj.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //var thisHeightLists = [];
  2. //var thisWrapper = null;
  3. //var thisScrollY = 0;
  4. //var thisIndex = 0;
  5. $(function () {
  6. initWrapperTop();
  7. $(".kj-category").click(function () {
  8. var index = $(".kj-category").index(this);
  9. $(".kj-category").removeClass("kj-active").eq(index).addClass("kj-active");
  10. $(".kj-item-wrapper").removeClass("kj-item-active").eq(index).addClass("kj-item-active");
  11. if (index == 2) {
  12. $(".v-item-list").removeClass("active").eq(0).addClass("active");
  13. $(".kj-high-lottery-category").removeClass("kj-active").eq(0).addClass("kj-active");
  14. }
  15. //if (index == 2 && thisWrapper == null) {
  16. // setTimeout(initScroll, 500);
  17. //}
  18. })
  19. $(".kj-high-lottery-category").click(function () {
  20. var index = $(".kj-high-lottery-category").index(this);
  21. $(".kj-high-lottery-category").removeClass("kj-active").eq(index).addClass("kj-active");
  22. $(".v-item-list").removeClass("active").eq(index).addClass("active");
  23. $(".content").scrollTop(0);
  24. //var itemLists = document.getElementsByClassName("v-item-list");
  25. //var el = itemLists[index];
  26. //thisWrapper.scrollToElement(el, 300);
  27. })
  28. })
  29. function initWrapperTop() {
  30. $("#ads-wrapper").show();
  31. setTimeout(function () {
  32. var h1 = $("#ads-wrapper").height();
  33. var h = h1 + 43;
  34. $("#wrapper1").css({ top: h + "px" })
  35. }, 150);
  36. }
  37. //function initScroll() {
  38. // var wrapper = document.getElementById("wrapper");
  39. // thisWrapper = new BScroll(wrapper, {
  40. // probeType: 3,
  41. // click: true
  42. // });
  43. // var height = 0;
  44. // thisHeightLists.push(height);
  45. // var itemLists = document.getElementsByClassName("v-item-list");
  46. // for (var i = 0; i < itemLists.length; i++) {
  47. // height += itemLists[i].clientHeight;
  48. // if (i == 2) {
  49. // height = height - 2;
  50. // }
  51. // console.log("height", height);
  52. // thisHeightLists.push(height);
  53. // }
  54. // thisWrapper.on("scroll", function (pos) {
  55. // thisScrollY = Math.abs(Math.round(pos.y));
  56. // for (var i = 0; i < thisHeightLists.length; i++) {
  57. // var height1 = thisHeightLists[i];
  58. // var height2 = thisHeightLists[i + 1];
  59. // if (!height2 || (thisScrollY >= height1 && thisScrollY < height2)) {
  60. // console.log("thisIndex", thisIndex);
  61. // console.log("thisHeightLists", thisHeightLists)
  62. // console.log("thisScrollY", thisScrollY)
  63. // thisIndex = i;
  64. // break;
  65. // }
  66. // }
  67. // $(".kj-high-lottery-category").removeClass("kj-active").eq(thisIndex).addClass("kj-active");
  68. // })
  69. //}