|
@@ -72,9 +72,9 @@ function renderContent(list, contentWrapClassName){
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var i = 0; i < list.length; i++) {
|
|
var item = list[i];
|
|
var item = list[i];
|
|
item.content = item.content&&item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
|
|
item.content = item.content&&item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
|
|
- anchors = '<li><i></i><a href="#' + item.title +
|
|
|
|
|
|
+ anchors = '<li><i></i><a href="#' + contentWrapClassName+i +
|
|
'">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
'">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
- str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + item.title +
|
|
|
|
|
|
+ str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + contentWrapClassName+i +
|
|
'">'
|
|
'">'
|
|
if (getUrlArgObject('type') == 8) {
|
|
if (getUrlArgObject('type') == 8) {
|
|
str += '【' + item.title + '】'
|
|
str += '【' + item.title + '】'
|
|
@@ -89,18 +89,19 @@ function renderContent(list, contentWrapClassName){
|
|
}
|
|
}
|
|
|
|
|
|
function addScrollEvent() {
|
|
function addScrollEvent() {
|
|
- var scrollTop = $('.infos').scrollTop()
|
|
|
|
|
|
+ var scrollTop = $(`.${contentWrapClassName} .infos`).scrollTop()
|
|
|
|
+
|
|
var divHeight = 0;
|
|
var divHeight = 0;
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var i = 0; i < list.length; i++) {
|
|
- divHeight = divHeight + parseInt($('#' + list[i].title).css('height')) + parseInt($('#' + list[i].title).parent().next().css('height')) + 20
|
|
|
|
|
|
+ divHeight = divHeight + parseInt($('#'+contentWrapClassName+i).css('height')) + parseInt($('#'+contentWrapClassName+i).parent().next().css('height')) + 20
|
|
if (divHeight > scrollTop) {
|
|
if (divHeight > scrollTop) {
|
|
var anchor = 2 * i;
|
|
var anchor = 2 * i;
|
|
- $('.anchors ul').children().eq(anchor).addClass('active').siblings().removeClass('active');
|
|
|
|
|
|
+ $(`.${contentWrapClassName} .anchors ul`).children().eq(anchor).addClass('active').siblings().removeClass('active');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $(".infos").scroll(throttle(addScrollEvent, 200));
|
|
|
|
|
|
+ $(`.${contentWrapClassName} .infos`).scroll(throttle(addScrollEvent, 200));
|
|
addLinkClickEvent(contentWrapClassName);
|
|
addLinkClickEvent(contentWrapClassName);
|
|
adjustHeight();
|
|
adjustHeight();
|
|
adjustWidth()
|
|
adjustWidth()
|
|
@@ -111,8 +112,13 @@ function renderContent(list, contentWrapClassName){
|
|
function addLinkClickEvent(contentWrapClassName) {
|
|
function addLinkClickEvent(contentWrapClassName) {
|
|
$(`.${contentWrapClassName} .anchors li:first`).addClass("active");
|
|
$(`.${contentWrapClassName} .anchors li:first`).addClass("active");
|
|
$(`.${contentWrapClassName} .anchors li>a`).on("click", function () {
|
|
$(`.${contentWrapClassName} .anchors li>a`).on("click", function () {
|
|
- $(`.${contentWrapClassName} .anchors .active`).removeClass('active');
|
|
|
|
- $(this).parent().addClass("active");
|
|
|
|
|
|
+
|
|
|
|
+ const that = this
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ $(`.${contentWrapClassName} .anchors .active`).removeClass('active');
|
|
|
|
+ $(that).parent().addClass("active");
|
|
|
|
+ },20)
|
|
|
|
+
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|