PageSourceSearch

https://getmegiddy.com/modules/themag_layouts/assets/js/sticky-columns.js?v=10.6.15

js getmegiddy.com collected 2026-09-24 09:00:04 UTC 2,343 bytes, 82 lines download raw bytes

1/**
2 * @file
3 * Sticky Kit
4 *
5 * @see http://leafo.net/sticky-kit/
6 */
7
8(function ($, Drupal, drupalSettings) {
9  'use strict';
10
11  // If sticky header is enabled, set off set_top to header height.
12  var stickyOptions = {};
13  if (typeof drupalSettings !== 'undefined' && drupalSettings.themag) {
14  if (drupalSettings.themag.header.stickyHeader === 1) {
15    var header = $('.js-sticky-header-element');
16    stickyOptions.offset_top = header.outerHeight() + 30;
17  }
18  }
19  Drupal.behaviors.themagLayouts = {
20    attach: function(context, settings) {
21
22      $(window).on('load', function() {
23        var largeScreen = window.matchMedia('(min-width: 768px)'),
24            stickyColumn = $('.js-sticky-column');
25
26        // Attach StickyKit to each compatible element.
27        stickyColumn.each(function(index, element) {
28          if (largeScreen.matches && isStickyCompatible($(element))) {
29            attachStickyColumns($(element), stickyOptions);
30          }
31        });
32
33        // Watch for screen changes.
34        largeScreen.addListener(function(mql) {
35          if (mql.matches) {
36            // Attach it to each compatible element.
37            stickyColumn.each(function(index, element) {
38              if (largeScreen.matches && isStickyCompatible($(element))) {
39                attachStickyColumns($(element), stickyOptions);
40              }
41            });
42          }
43          else {
44            detachStickyColumns(stickyColumn);
45          }
46        });
47      });
48    }
49  };
50
51  /*
52   * Attach Sticky Kit
53   */
54  function attachStickyColumns(element, options) {
55    var stickyElement = element.find('>div');
56    stickyElement.stick_in_parent(options);
57  }
58
59  /*
60   * Detach Sticky Kit
61   */
62  function detachStickyColumns(element) {
63    var stickyElement = element.find('>div');
64    stickyElement.trigger('sticky_kit:detach');
65  }
66
67  /*
68   * Check if sticky elements column is higher than static elements column.
69   * If it is, then it will be considered as incompatible.
70   */
71  function isStickyCompatible(element) {
72    var parentHeight = element.parent().height(),
73      stickyElement = element.find('>div'),
74      stickyElementHeight = stickyElement.css('padding-bottom', '1px').height() + 100;
75
76    if (stickyElementHeight >= parentHeight) {
77      return false;
78    }
79    return true;
80  }
81
82}(jQuery, Drupal, 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.