mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-29 18:16:17 +01:00 
			
		
		
		
	fix: navigation fixes
This commit is contained in:
		| @@ -341,14 +341,13 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co | |||||||
| 		var scrollTop = $(window).scrollTop(); | 		var scrollTop = $(window).scrollTop(); | ||||||
| 		var windowHeight = $(window).height(); | 		var windowHeight = $(window).height(); | ||||||
| 		var documentHeight = $(document).height(); | 		var documentHeight = $(document).height(); | ||||||
| 		var navbarHeight = components.get('navbar').outerHeight(true); | 		var middleOfViewport = scrollTop + (windowHeight / 2); | ||||||
| 		var topicHeaderHeight = $('.topic-header').height() || 0; |  | ||||||
| 		var middleOfViewport = scrollTop + (windowHeight / 2) - navbarHeight - topicHeaderHeight; |  | ||||||
| 		var previousDistance = Number.MAX_VALUE; | 		var previousDistance = Number.MAX_VALUE; | ||||||
| 		els.each(function () { | 		els.each(function () { | ||||||
| 			var elIndex = parseInt($(this).attr('data-index'), 10); | 			var $this = $(this); | ||||||
|  | 			var elIndex = parseInt($this.attr('data-index'), 10); | ||||||
| 			if (elIndex >= 0) { | 			if (elIndex >= 0) { | ||||||
| 				var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top); | 				var distanceToMiddle = Math.abs(middleOfViewport - ($this.offset().top + ($this.outerHeight(true) / 2))); | ||||||
| 				if (distanceToMiddle > previousDistance) { | 				if (distanceToMiddle > previousDistance) { | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| @@ -512,10 +511,11 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co | |||||||
| 			navigator.scrollActive = false; | 			navigator.scrollActive = false; | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		var postHeight = scrollTo.height(); |  | ||||||
|  | 		var postHeight = scrollTo.outerHeight(true); | ||||||
| 		var navbarHeight = components.get('navbar').outerHeight(true); | 		var navbarHeight = components.get('navbar').outerHeight(true); | ||||||
| 		var topicHeaderHeight = $('.topic-header').height() || 0; | 		var topicHeaderHeight = $('.topic-header').outerHeight(true) || 0; | ||||||
| 		var viewportHeight = $(window).height() - navbarHeight - topicHeaderHeight; | 		var viewportHeight = $(window).height(); | ||||||
|  |  | ||||||
| 		// Temporarily disable navigator update on scroll | 		// Temporarily disable navigator update on scroll | ||||||
| 		$(window).off('scroll', navigator.delayedUpdate); | 		$(window).off('scroll', navigator.delayedUpdate); | ||||||
| @@ -545,8 +545,8 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			var scrollTop = 0; | 			var scrollTop = 0; | ||||||
| 			if (postHeight < viewportHeight) { | 			if (postHeight < viewportHeight - navbarHeight - topicHeaderHeight) { | ||||||
| 				scrollTop = (scrollTo.offset().top - (viewportHeight / 2) + (postHeight)) - topicHeaderHeight; | 				scrollTop = scrollTo.offset().top - (viewportHeight / 2) + (postHeight / 2); | ||||||
| 			} else { | 			} else { | ||||||
| 				scrollTop = scrollTo.offset().top - navbarHeight - topicHeaderHeight; | 				scrollTop = scrollTo.offset().top - navbarHeight - topicHeaderHeight; | ||||||
| 			} | 			} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user