PageSourceSearch

https://mbpg.gov.my/modules/contrib/back_to_top/js/back_to_top.js?v=10.1.0

js mbpg.gov.my collected 2026-10-02 22:08:24 UTC 2,119 bytes, 67 lines download raw bytes

1/**
2 * @file
3 * Back To Top behaviors.
4 */
5(function ($, Drupal, once, drupalSettings) {
6
7  var scrollTo = function (to, duration) {
8    var element = document.scrollingElement || document.documentElement,
9      start = element.scrollTop,
10      change = to - start,
11      startTs = performance.now(),
12      easeOutQuart = function (t, b, c, d) {
13	      t /= d;
14	      t--;
15	      return -c * (t * t * t * t - 1) + b;
16      },
17      animateScroll = function (ts) {
18        var currentTime = ts - startTs;
19        element.scrollTop = parseInt(easeOutQuart(currentTime, start, change, duration));
20        if (currentTime < duration) {
21          frame = requestAnimationFrame(animateScroll);
22        } else {
23          element.scrollTop = to;
24        }
25      };
26    requestAnimationFrame(animateScroll);
27  };
28
29  Drupal.behaviors.backtotop = {
30    attach: function (context, settings) {
31      let isMobile = window.matchMedia("only screen and (max-width: 760px)").matches;
32      if (!(settings.back_to_top.back_to_top_prevent_on_mobile && isMobile)) {
33        var exist = $('#backtotop').length;
34        if (exist == 0) {
35          $(once('backtotop', 'body'), context).each(function () {
36            $('body').append("<button id='backtotop' aria-label='" + Drupal.t("Back to top") + "'>" + settings.back_to_top.back_to_top_button_text + "</button>");
37          });
38        }
39      }
40
41      backToTop();
42      $(window).scroll(function () {
43        backToTop();
44      });
45
46      $(once('backtotop', '#backtotop'), context).each(function () {
47        $(this).click(function () {
48          $("html, body").bind("scroll mousedown DOMMouseScroll mousewheel keyup", function () {
49            window.cancelAnimationFrame(frame);
50          });
51          scrollTo(0, 1200);
52        });
53      });
54
55      /**
56       * Hide show back to top links.
57       */
58      function backToTop() {
59        if ($(window).scrollTop() > settings.back_to_top.back_to_top_button_trigger) {
60          $('#backtotop').fadeIn();
61        } else {
62          $('#backtotop').fadeOut();
63        }
64      }
65    }
66  };
67})(jQuery, Drupal, once, drupalSettings);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.