PageSourceSearch

https://www.nishikawa1566.com/lib/jquery-fixHeightSimple.min.js

js nishikawa1566.com collected 2026-09-24 18:14:07 UTC 2,414 bytes, 83 lines download raw bytes

1/*---------------------------------------------
2 * jQuery Fix Height Simple 2.3 - 2017-03-01
3---------------------------------------------*/
4jQuery.fn.fixHeightSimple = function (a) {
5
6  function getColGapPx($parent) {
7    var el = $parent && $parent[0];
8    if (!el) return 0;
9
10    var cs = window.getComputedStyle(el);
11    // grid/flex どちらも columnGap / gap を見る(環境差吸収)
12    var gap = cs.columnGap || cs.gap || "0px";
13
14    // "normal" の場合は 0 扱い(ブラウザ依存で算出困難)
15    if (gap === "normal") return 0;
16
17    var v = parseFloat(gap);
18    return isNaN(v) ? 0 : v;
19  }
20
21  function calcColumns(parentW, itemW, gap) {
22    // gap込み: (親幅 + gap) / (要素幅 + gap)
23    if (!itemW) return 1;
24    var cols = Math.floor((parentW + gap) / (itemW + gap));
25    return Math.max(1, cols);
26  }
27
28  function c() {
29    var parentW, itemW;
30
31    if (a.boxSizingBorderBox) {
32      parentW = a.responsiveParent.outerWidth();
33      itemW = b.eq(0).outerWidth();
34    } else {
35      parentW = a.responsiveParent.width();
36      itemW = b.eq(0).width();
37    }
38
39    // ★追加:gap を取って列数を計算
40    if (a.responsive) {
41      var gap = getColGapPx(a.responsiveParent);
42      a.column = calcColumns(parentW, itemW, gap);
43    }
44
45    if (1 != a.column) {
46      var e = new Array(120), f = 0;
47      b.css("height", "auto");
48
49      for (var g = 0; g < b.length; g++) {
50        var h = b.eq(g);
51
52        if (a.boxSizingBorderBox) e[g] = h.outerHeight();
53        else e[g] = h.height();
54
55        if (e[g] > f) f = e[g];
56
57        if (a.column) {
58          var i = (g + 1) % a.column;
59
60          if (0 != g && 0 == i || g + 1 == b.length) {
61            var j = g - a.column;
62            if (g + 1 == b.length) {
63              j = g + 1 < a.column ? -1 : (0 == i ? g - a.column : g - i);
64            }
65
66            for (var k = j; k < g; k++) b.eq(k + 1).css("height", f + "px");
67            f = 0;
68          }
69        }
70      }
71
72      a.column || b.css("height", f + "px");
73    } else {
74      b.css("height", "auto");
75    }
76  }
77
78  a = jQuery.extend({ column: 0, responsive: !1, responsiveParent: "body", boxSizingBorderBox: !1 }, a);
79  var b = this;
80
81  a.responsiveParent = jQuery(a.responsiveParent);
82  b.length > 0 && (c(), jQuery(window).on("load resize", function () { c(); }));
83};

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.