1
0
فهرست منبع

anchor link on non-front-page pages fixed

Moritz Schmidt 9 سال پیش
والد
کامیت
25758c1b28
2فایلهای تغییر یافته به همراه4 افزوده شده و 21 حذف شده
  1. 4 0
      dist/wp_bootstrap_navwalker.php
  2. 0 21
      footer.php

+ 4 - 0
dist/wp_bootstrap_navwalker.php

@@ -98,6 +98,10 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
 
 			$atts['class'] = "nav-link scroll-link"; // MY EDIT
 			$atts['data-target'] = ltrim($atts['href'], '/');
+			$atts['href'] = ltrim($atts['href'], '/');
+			if(!is_front_page()) {
+				$atts['href'] = "/index.php" . $atts['href'];
+			}
 
 			$attributes = '';
 			foreach ( $atts as $attr => $value ) {

+ 0 - 21
footer.php

@@ -42,27 +42,6 @@
           }, 500);
         });
 
-        $(document).on('click', 'a.nav-link.scroll-link[data-target*="#"]', function(e){
-          e.preventDefault();
-
-          $('html, body').animate({
-            scrollTop: $( $.attr(this, 'data-target') ).offset().top
-          }, 500);
-        });
-
-        /*$(document).on('click', 'a.nav-link.scroll-link[href*="\#"]', function(e) {
-          e.preventDefault();
-
-          var target = $(this).attr('href'), $target = $(target); {
-            $('html, body').stop().animate({
-                'scrollTop' : $target.offset().top - 50
-            }, 900, 'swing', function() {
-                window.location.hash = target;
-            });
-          }
-        });*/
-
-
       });
     </script>
   </body>