module/flk/themes/index/flk_category/index.js

(完整代码) 1KB

var catScroll = {
	wh: $(window).height(),
	eIndex: ".list-side-item",  
	eBoxs: ".list-cat-item", 
	lastY: 0,
	lastIndex: 0,
	top:100,
	init: function() {
		var that=this;
		var $eIndex = $(this.eIndex);
		var $eBoxs = $(that.eBoxs);
		var a = $eIndex.eq(that.lastIndex).addClass("active");
		$(document).on("click", that.eIndex, function(e) {
			$(this).addClass("active").siblings().removeClass("active");
			var st = $eBoxs.eq($(this).index()).offset().top - 100;
			$(window).scrollTop(st);
			that.lastY = st;
			that.lastIndex = $(this).index();
		})

		$(document).on("scroll", function(e) {
			var st = $(this).scrollTop();
			if(st > that.lastY) { /*向上拉*/
				var eBox = $eBoxs.eq(that.lastIndex + 1);
				if(eBox.length == 0) return false;

				if(st + that.top > eBox.offset().top) {
					that.lastY = st;
					$eIndex.eq(that.lastIndex + 1).addClass("active").siblings().removeClass("active");
					that.lastIndex++;
				}

			} else { /*向下拉*/
				var eindex = that.lastIndex - 1;

				if(eindex < 0) return false;
				var eBox = $eBoxs.eq(eindex);
				if(eBox.length == 0) return false;
				var thisBox = $eBoxs.eq(that.lastIndex);

				if(st + that.top+100 < thisBox.offset().top) {
					that.lastY = st;
					$eIndex.eq(eindex).addClass("active").siblings().removeClass("active");
					that.lastIndex = eindex;
				}
			}

		})
	}
}
catScroll.init();

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。