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,17 +105,18 @@ $(function() {
105 105
				}
106 106
				
107 107
				var articletitle = data.data.articleTitle + "-科袖网";
108
				document.title = articletitle;
108 109
				window.setTimeout(function() {
109
					document.title = articletitle;
110
					$('body').scrollTop(4);
110 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 121
			"error":function(){
121 122
				$.MsgBox.Alert('提示','链接服务器超时')

+ 19 - 1
js/scrollfix.js

@ -26,6 +26,7 @@
26 26
			var originalZIndex;
27 27
			var lastOffsetLeft = -1;
28 28
			var isUnfixed = true;
29
			var o_h =(window.document.body || window.document.documentElement).scrollHeight;
29 30
			//如果没有找到节点,不进行处理
30 31
			if (obj.length <= 0) {
31 32
				return;
@ -191,11 +192,28 @@
191 192
			resetScroll();
192 193
			// }
193 194
			$(window).on("scroll", function() {
195
				var n_h=(window.document.body || window.document.documentElement).scrollHeight;
194 196
				if (Timer) {
195 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 218
			$(window).on("resize", function() {
201 219
				if (Timer) {