ancre js
This commit is contained in:
@@ -194,54 +194,68 @@ jQuery(document).ready(function($){
|
||||
//// ancre dans texte au click parragraphe correspondant arrive en dessous du header
|
||||
|
||||
|
||||
// (function($, window) {
|
||||
// var adjustAnchor = function() {
|
||||
// var $anchor = $('.block-region-first'),
|
||||
// fixedElementHeight = 300;
|
||||
// console.log($anchor);
|
||||
// if ($anchor.length > 0) {
|
||||
// $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight }, 0);
|
||||
// }
|
||||
// };
|
||||
|
||||
// function adjustAnchor() {
|
||||
// var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
|
||||
// var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
|
||||
// $(window).on('hashchange', function() {
|
||||
// adjustAnchor();
|
||||
// });
|
||||
// });
|
||||
|
||||
// if ($anchor.length > 0) {
|
||||
// $('html, body').stop().animate({
|
||||
// scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
|
||||
// }, 0);
|
||||
// }
|
||||
// }
|
||||
function adjustAnchor() {
|
||||
var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
|
||||
var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
|
||||
|
||||
// // Call the function on page load if there's a hash
|
||||
// if (window.location.hash) {
|
||||
// adjustAnchor();
|
||||
// }
|
||||
if ($anchor.length > 0) {
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// // Adjust the anchor on hash change
|
||||
// $(window).on('hashchange', function() {
|
||||
// adjustAnchor();
|
||||
// });
|
||||
// Call the function on page load if there's a hash
|
||||
if (window.location.hash) {
|
||||
adjustAnchor();
|
||||
}
|
||||
|
||||
// Adjust the anchor on hash change
|
||||
$(window).on('hashchange', function() {
|
||||
adjustAnchor();
|
||||
});
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// menu ancre paragraphe quand actif
|
||||
|
||||
jQuery(function($) {
|
||||
// Function to set the active class based on the current path
|
||||
function setActiveLink() {
|
||||
var path = window.location.href;
|
||||
console.log(path);
|
||||
$(".layout__region--first .block-region-first li a").each(function() {
|
||||
if (this.href === path) {
|
||||
$(this).closest('a').addClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
jQuery(function($) {
|
||||
// Function to set the active class based on the current path
|
||||
function setActiveLink() {
|
||||
var path = window.location.href;
|
||||
console.log(path);
|
||||
$(".layout__region--first .block-region-first li a").each(function() {
|
||||
if (this.href === path) {
|
||||
$(this).closest('a').addClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initially set the active link based on the current URL
|
||||
setActiveLink();
|
||||
// Initially set the active link based on the current URL
|
||||
setActiveLink();
|
||||
|
||||
// Update the active link on click
|
||||
$(".layout__region--first .block-region-first li a").on('click', function() {
|
||||
$(".layout__region--first .block-region-first li a").removeClass('active');
|
||||
$(this).addClass('active');
|
||||
});
|
||||
// Update the active link on click
|
||||
$(".layout__region--first .block-region-first li a").on('click', function() {
|
||||
$(".layout__region--first .block-region-first li a").removeClass('active');
|
||||
$(this).addClass('active');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
})(jQuery, window);
|
||||
|
||||
Reference in New Issue
Block a user