Prechádzať zdrojové kódy

lien anchor reste sous header au click

ouidade 3 rokov pred
rodič
commit
7ee8e2a9fd
1 zmenil súbory, kde vykonal 17 pridanie a 9 odobranie
  1. 17 9
      web/themes/custom/eql/scripts/main.js

+ 17 - 9
web/themes/custom/eql/scripts/main.js

@@ -135,15 +135,23 @@ jQuery(function($) {
 
 
 
 
 // /////////////////
 // /////////////////
-//// ancre dans texte
-// document.querySelector('.paragraph--view-mode--textes-toc').click( function() {
-//   var page = this.attr('href'); 
-//   var speed = 750; // gérer la vitesse de défliement
-      
-//       // Ici on retranche la hauteur du bandeau (201px dans ta feuille de styles)
-// document.querySelector('html, body').animate( { scrollTop: page.offset().top - 500 }, speed );
-//   return false;
-// });
+//// ancre dans texte au click parragraphe correspondant arrive en dessous du header 
+
+
+(function($, window) {
+  var adjustAnchor = function() {
+      var $anchor = $('.block-entity-fieldnodefield-textes'),
+              fixedElementHeight = 350;
+      if ($anchor.length > 0) {
+          $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight}, 250);
+      }
+  };
+
+  $(window).on('hashchange load', function() {
+      adjustAnchor();
+  });
+
+})(jQuery, window);
 
 
 
 
 // ///////////////////////////////
 // ///////////////////////////////