|
@@ -5,9 +5,12 @@ $(function () {
|
|
maxlength: null,
|
|
maxlength: null,
|
|
};
|
|
};
|
|
// 实现跳转
|
|
// 实现跳转
|
|
|
|
+ let my_nav = $(".my-nav"), top = my_nav.offset().top;
|
|
$(".my-nav").click(function (e) {
|
|
$(".my-nav").click(function (e) {
|
|
|
|
+ if (e.target.className == "my-nav") return false;
|
|
let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target);
|
|
let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target);
|
|
if (active == globaldata.active) return false;
|
|
if (active == globaldata.active) return false;
|
|
|
|
+ globaldata.active = active;
|
|
$(this).find(".active").removeClass("active");
|
|
$(this).find(".active").removeClass("active");
|
|
$(e.target).addClass("active");
|
|
$(e.target).addClass("active");
|
|
// 获取跳转锚点到顶部的距离
|
|
// 获取跳转锚点到顶部的距离
|
|
@@ -20,6 +23,14 @@ $(function () {
|
|
let maos = [title, edi_answer, interactive];
|
|
let maos = [title, edi_answer, interactive];
|
|
$(window).scrollTop(maos[i]);
|
|
$(window).scrollTop(maos[i]);
|
|
})
|
|
})
|
|
|
|
+ $(window).scroll(
|
|
|
|
+ function () {
|
|
|
|
+ let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
|
+ if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
|
|
|
|
+ my_nav.removeClass("fixed")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ )
|
|
// 查看更多
|
|
// 查看更多
|
|
$("[data-click='open']").click(function () {
|
|
$("[data-click='open']").click(function () {
|
|
let bool = $(this).data("open");
|
|
let bool = $(this).data("open");
|
|
@@ -30,83 +41,6 @@ $(function () {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- // 进度条拖动
|
|
|
|
- window.onresize = function () {
|
|
|
|
- globaldata.maxlength = $(".pro").width();
|
|
|
|
- }
|
|
|
|
- // 进度条宽度
|
|
|
|
- let maxlength = globaldata.maxlength || $(".pro").width();
|
|
|
|
- // 移动dom
|
|
|
|
- let movedom = $(".pro>.icon");
|
|
|
|
- //起始坐标
|
|
|
|
- let startX = null;
|
|
|
|
- // 分数
|
|
|
|
- let gross = $(".pro").data("gross");
|
|
|
|
- // 进度条
|
|
|
|
- let showdom = $(".pro>.pro-content");
|
|
|
|
- // 显示数值
|
|
|
|
- let pro_show = $(".pro>.pro-show");
|
|
|
|
-
|
|
|
|
- movedom.mousedown(function (e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- $(".prog>.title").hide();
|
|
|
|
- $(".pro>.pro-title").hide();
|
|
|
|
- startX = e.pageX;
|
|
|
|
- $(this).css('left') ? $(this).css('left') : $(this).css('left', '0px');
|
|
|
|
- let startLeft = parseInt($(this).css('left'));
|
|
|
|
- let $that = $(this);
|
|
|
|
- document.onmousemove = function (e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- let moveX = (e.pageX - startX) > 0 ? true : false;
|
|
|
|
- let movesection = startLeft + (e.pageX - startX);
|
|
|
|
- if (movesection >= 0 && movesection <= maxlength) {
|
|
|
|
- let percent = (movesection / maxlength).toFixed(4) * gross;
|
|
|
|
- percent = Math.round(percent) + "分";
|
|
|
|
- let move = movesection + "px";
|
|
|
|
- showdom.css("width", move);
|
|
|
|
- pro_show.css("left", move).text(percent);
|
|
|
|
- $that.css("left", move)
|
|
|
|
- window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- movedom.mouseup(function () { document.onmousemove = null })
|
|
|
|
- movedom.mouseleave(function () { document.onmousemove = null })
|
|
|
|
- // 手机端更改
|
|
|
|
- let x1, y1, oldTime, newTime, olfLeft, newLeft;
|
|
|
|
- movedom[0].addEventListener("touchstart", function (e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- $(".prog>.title").hide();
|
|
|
|
- $(".pro>.pro-title").hide();
|
|
|
|
- var touches = e.changedTouches;
|
|
|
|
- x1 = touches[0].pageX;
|
|
|
|
- olfLeft = this.offsetLeft;
|
|
|
|
- }, false)
|
|
|
|
-
|
|
|
|
- movedom[0].addEventListener("touchmove", function (e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- var x2 = e.changedTouches[0].pageX;
|
|
|
|
- newLeft = x2 - x1;
|
|
|
|
- nowLeft = olfLeft + newLeft;
|
|
|
|
- if (nowLeft < 0) {
|
|
|
|
- nowLeft = 0;
|
|
|
|
- }
|
|
|
|
- if (nowLeft > maxlength) {
|
|
|
|
- nowLeft = maxlength;
|
|
|
|
- }
|
|
|
|
- showdom.css("width", nowLeft + "px");
|
|
|
|
- $(this).css("left", nowLeft + "px");
|
|
|
|
- let percent = nowLeft / maxlength * gross;
|
|
|
|
- percent = Math.round(percent);
|
|
|
|
- pro_show.css("left", nowLeft).text(percent);
|
|
|
|
- }, false)
|
|
|
|
- function handleEnd (e) {
|
|
|
|
- this.removeEventListener("touchmove", handleEnd, false);
|
|
|
|
- }
|
|
|
|
- movedom[0].addEventListener("touchend", function () {
|
|
|
|
- this.removeEventListener("touchmove", handleEnd, false);
|
|
|
|
- }, false)
|
|
|
|
-
|
|
|
|
// 不能实现的事件
|
|
// 不能实现的事件
|
|
function warm () {
|
|
function warm () {
|
|
alert("请在大联考App内登录后操作")
|
|
alert("请在大联考App内登录后操作")
|