|
@@ -2,27 +2,28 @@
|
|
|
|
|
|
$(function () {
|
|
|
// 页面滚动偏移
|
|
|
- var offset = 0; // 生成导航
|
|
|
-
|
|
|
+ var offset = 0;
|
|
|
+ var windowWidth = $(window).width();
|
|
|
+ var timer = null; // 定时器
|
|
|
+ var middleScreenWidth = 1450;
|
|
|
+ // 生成导航
|
|
|
makeNavigate('.section h2', '.navigate');
|
|
|
-
|
|
|
- if ($(window).width() > 768) {
|
|
|
+ if (windowWidth > 768) {
|
|
|
offset = getScrollOffset('.navbar') + 10;
|
|
|
} else {
|
|
|
offset = getScrollOffset(['.navbar', '.navigate']) + 10;
|
|
|
- } // 侧边导航跳转
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ // 侧边导航跳转
|
|
|
bindCategory('.navigate li', '.section', offset, function (index) {
|
|
|
activeCategory('.navigate li', index);
|
|
|
- }); // 页面滚动观测
|
|
|
-
|
|
|
+ });
|
|
|
+ // 页面滚动观测
|
|
|
pageScrollObserve('.section', offset, function (el, index) {
|
|
|
if (index > -1) {
|
|
|
activeCategory('.navigate li', index);
|
|
|
}
|
|
|
- }); // 常见问题展开收起
|
|
|
-
|
|
|
+ });
|
|
|
+ // 常见问题展开收起
|
|
|
$('[data-toggle="collapse"]').each(function (index, el) {
|
|
|
var targetEl = $(el).attr('data-target');
|
|
|
if (!targetEl) return;
|
|
@@ -39,4 +40,30 @@ $(function () {
|
|
|
$('#contactPopupClose').on('click', function () {
|
|
|
$('#contactPopup').hide();
|
|
|
});
|
|
|
+ // 切换显示侧边导航
|
|
|
+ function toggleNavigate(selector, time, maxWidth, offset) {
|
|
|
+ selector = $(selector);
|
|
|
+ if(windowWidth <= middleScreenWidth){
|
|
|
+ selector.hide();
|
|
|
+ }
|
|
|
+ // 鼠标移动事件
|
|
|
+ $('body').on('mousemove', function (e) {
|
|
|
+ var width = $(this).width();
|
|
|
+ if (!(e.clientX > width - offset && width <= maxWidth)) return;
|
|
|
+ clearTimeout(timer);
|
|
|
+ selector.fadeIn();
|
|
|
+ timer = setTimeout(function () {
|
|
|
+ selector.fadeOut();
|
|
|
+ }, time)
|
|
|
+ });
|
|
|
+ // 窗口大小改变
|
|
|
+ $(window).resize(function () {
|
|
|
+ if ($(this).width() <= maxWidth) {
|
|
|
+ selector.hide();
|
|
|
+ }else{
|
|
|
+ selector.show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ toggleNavigate('.navigate', 1000, middleScreenWidth, 80);
|
|
|
});
|