Browse Source

文章悬浮操作栏定位问题

luyanan 7 years ago
parent
commit
6c07447d16
2 changed files with 29 additions and 10 deletions
  1. 10 9
      js/articalShow.js
  2. 19 1
      js/scrollfix.js

+ 10 - 9
js/articalShow.js

105
				}
105
				}
106
				
106
				
107
				var articletitle = data.data.articleTitle + "-科袖网";
107
				var articletitle = data.data.articleTitle + "-科袖网";
108
				document.title = articletitle;
108
				window.setTimeout(function() {
109
				window.setTimeout(function() {
109
					document.title = articletitle;
110
					$('body').scrollTop(4);
110
					var oShareW = $('.share-nav').outerWidth(true);
111
					var oShareW = $('.share-nav').outerWidth(true);
111
		$('.shareBlock').scrollFix( {
112
	        startTop:'body',
113
	        bottom: '0',
114
	        endPos : '.share-bottom',
115
			width: oShareW ,
116
	        zIndex : 997
117
	    });	
118
				}, 500);
112
					$('.shareBlock').scrollFix( {
113
				        startTop:'body',
114
				        bottom: '0',
115
				        endPos : '.share-bottom',
116
						width: oShareW ,
117
				        zIndex : 997
118
				    });	
119
				}, 300);
119
			},
120
			},
120
			"error":function(){
121
			"error":function(){
121
				$.MsgBox.Alert('提示','链接服务器超时')
122
				$.MsgBox.Alert('提示','链接服务器超时')

+ 19 - 1
js/scrollfix.js

26
			var originalZIndex;
26
			var originalZIndex;
27
			var lastOffsetLeft = -1;
27
			var lastOffsetLeft = -1;
28
			var isUnfixed = true;
28
			var isUnfixed = true;
29
			var o_h =(window.document.body || window.document.documentElement).scrollHeight;
29
			//如果没有找到节点,不进行处理
30
			//如果没有找到节点,不进行处理
30
			if (obj.length <= 0) {
31
			if (obj.length <= 0) {
31
				return;
32
				return;
191
			resetScroll();
192
			resetScroll();
192
			// }
193
			// }
193
			$(window).on("scroll", function() {
194
			$(window).on("scroll", function() {
195
				var n_h=(window.document.body || window.document.documentElement).scrollHeight;
194
				if (Timer) {
196
				if (Timer) {
195
					clearTimeout(Timer);
197
					clearTimeout(Timer);
196
				}
198
				}
197
				Timer = setTimeout(onScroll, 0);
199
				if(n_h === o_h){
200
					Timer = setTimeout(onScroll, 0);
201
				}else{
202
					o_h = n_h;
203
					Timer = setTimeout(function(){
204
						isUnfixed=false;
205
						resetScroll();
206
						onScroll();
207
					},0);
208
				}
209
					
198
			});
210
			});
211
//			$(window).on("scroll", function() {
212
//				if (Timer) {
213
//					clearTimeout(Timer);
214
//				}
215
//				Timer = setTimeout(onScroll, 0);
216
//			});
199
			// 当发现调整屏幕大小时,重新执行代码
217
			// 当发现调整屏幕大小时,重新执行代码
200
			$(window).on("resize", function() {
218
			$(window).on("resize", function() {
201
				if (Timer) {
219
				if (Timer) {