MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus DG HochN-Wiki
Die Seite wurde neu angelegt: „→Das folgende JavaScript wird für alle Benutzer geladen.: (function($, window) { var adjustAnchor = function() { var $anchor = $(':ta…“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
/* Offset für fixed Navigation bei Ankerlinks */ | |||
(function($, window) { | (function($, window) { | ||
var adjustAnchor = function() { | var adjustAnchor = function() { | ||
| Zeile 7: | Zeile 9: | ||
if ($anchor.length > 0) { | if ($anchor.length > 0) { | ||
/* With animation */ | |||
// $('html, body') | |||
// .stop() | |||
// .animate({ | |||
// scrollTop: $anchor.offset().top - fixedElementHeight | |||
// }, 200); | |||
/* Without animation */ | |||
window.scrollTo(0, $anchor.offset().top - fixedElementHeight); | |||
} | } | ||
Version vom 27. Juni 2024, 10:11 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Offset für fixed Navigation bei Ankerlinks */
(function($, window) {
var adjustAnchor = function() {
var $anchor = $(':target'),
fixedElementHeight = 100;
if ($anchor.length > 0) {
/* With animation */
// $('html, body')
// .stop()
// .animate({
// scrollTop: $anchor.offset().top - fixedElementHeight
// }, 200);
/* Without animation */
window.scrollTo(0, $anchor.offset().top - fixedElementHeight);
}
};
$(window).on('hashchange load', function() {
adjustAnchor();
});
})(jQuery, window);