MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus DG HochN-Wiki
Wechseln zu:Navigation, Suche
(Die Seite wurde neu angelegt: „→‎Das folgende JavaScript wird für alle Benutzer geladen.: (function($, window) { var adjustAnchor = function() { var $anchor = $(':ta…“)
 
 
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);
  
                 $('html, body')
+
                 /* Without animation */
                    .stop()
+
                window.scrollTo(0, $anchor.offset().top - fixedElementHeight);
                    .animate({
 
                        scrollTop: $anchor.offset().top - fixedElementHeight
 
                    }, 200);
 
  
 
             }
 
             }

Aktuelle Version vom 27. Juni 2024, 11: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);
Cookies helfen uns bei der Bereitstellung von DG HochN-Wiki. Durch die Nutzung von DG HochN-Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.