소스 검색

Fixes #147 - a flicker occurs when click the active panels menu item. This seems to be caused by the offset variable to account for the admin bar displaying.

Jeffrey Pearce 7 년 전
부모
커밋
c2f6557f18
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      pique/assets/js/front-page.js

+ 6 - 2
pique/assets/js/front-page.js

@@ -55,13 +55,17 @@
 
 		// Use scrollTo library to smoothly scroll between panels.
 		// Note that the admin bar lenght is only taken into consideration on screen size > 480px, when it becomes fixed.
-		// Also, we take into account he height of the primary menu after 768px.
+		// Also, we take into account the height of the primary menu after 768px.
 		$navLinks.click( function() {
 			var yCoord = ( 1 === $adminBar.length && $( window ).outerWidth() > 480 ) ? $adminBar.outerHeight() : 0;
 			var offset = $( window ).outerWidth() > 768 ? $primaryMenu.outerHeight() : 0;
+			var offsetParams = {};
+			if ($('#wpadminbar').length > 0) {
+				offsetParams = { 'top': -1 * ( yCoord + offset ) };
+			}
 			$.scrollTo( $( this ).attr( 'href' ), {
 				duration: 400,
-				offset: { 'top': -1 * ( yCoord + offset ) }
+				offset: offsetParams
 			} );
 		});
 	}