vendor: 7,462 bytes, lines 1-216
1/*! 2 Sticky-kit 3 Version: 1.1.3 4 Plugin URL: https://github.com/leafo/sticky-kit 5 License: Leaf Corcoran 2015 | Licensed under MIT 6!*/ 7 8(function() { 9 var $, win; 10 11 $ = window.jQuery; 12 13 win = $(window); 14 15 $.fn.stick_in_parent = function(opts) { 16 var doc, elm, enable_bottoming, fn, i, inner_scrolling, len, manual_spacer, offset_top, outer_width, parent_selector, recalc_every, sticky_class; 17 if (opts == null) { 18 opts = {}; 19 } 20 sticky_class = opts.sticky_class, inner_scrolling = opts.inner_scrolling, recalc_every = opts.recalc_every, parent_selector = opts.parent, offset_top = opts.offset_top, manual_spacer = opts.spacer, enable_bottoming = opts.bottoming; 21 if (offset_top == null) { 22 offset_top = 0; 23 } 24 if (parent_selector == null) { 25 parent_selector = void 0; 26 } 27 if (inner_scrolling == null) { 28 inner_scrolling = true; 29 } 30 if (sticky_class == null) { 31 sticky_class = "is_stuck"; 32 } 33 doc = $(document); 34 if (enable_bottoming == null) { 35 enable_bottoming = true; 36 } 37 outer_width = function(el) { 38 var _el, computed, w; 39 if (window.getComputedStyle) { 40 _el = el[0]; 41 computed = window.getComputedStyle(el[0]); 42 w = parseFloat(computed.getPropertyValue("width")) + parseFloat(computed.getPropertyValue("margin-left")) + parseFloat(computed.getPropertyValue("margin-right")); 43 if (computed.getPropertyValue("box-sizing") !== "border-box") { 44 w += parseFloat(computed.getPropertyValue("border-left-width")) + parseFloat(computed.getPropertyValue("border-right-width")) + parseFloat(computed.getPropertyValue("padding-left")) + parseFloat(computed.getPropertyValue("padding-right")); 45 } 46 return w; 47 } else { 48 return el.outerWidth(true); 49 } 50 }; 51 fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) { 52 var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick; 53 if (elm.data("sticky_kit")) { 54 return; 55 } 56 elm.data("sticky_kit", true); 57 last_scroll_height = doc.height(); 58 parent = elm.parent(); 59 if (parent_selector != null) { 60 parent = parent.closest(parent_selector); 61 } 62 if (!parent.length) { 63 throw "failed to find stick parent"; 64 } 65 fixed = false; 66 bottomed = false; 67 spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />"); 68 if (spacer) { 69 spacer.css('position', elm.css('position')); 70 } 71 recalc = function() { 72 var border_top, padding_top, restore; 73 if (detached) { 74 return; 75 } 76 last_scroll_height = doc.height(); 77 border_top = parseInt(parent.css("border-top-width"), 10); 78 padding_top = parseInt(parent.css("padding-top"), 10); 79 padding_bottom = parseInt(parent.css("padding-bottom"), 10); 80 parent_top = parent.offset().top + border_top + padding_top; 81 parent_height = parent.height(); 82 if (fixed) { 83 fixed = false; 84 bottomed = false; 85 if (manual_spacer == null) { 86 elm.insertAfter(spacer); 87 spacer.detach(); 88 } 89 elm.css({ 90 position: "", 91 top: "", 92 width: "", 93 bottom: "" 94 }).removeClass(sticky_class); 95 restore = true; 96 } 97 top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top; 98 height = elm.outerHeight(true); 99 el_float = elm.css("float"); 100 if (spacer) { 101 spacer.css({ 102 width: outer_width(elm), 103 height: height, 104 display: elm.css("display"), 105 "vertical-align": elm.css("vertical-align"), 106 "float": el_float 107 }); 108 } 109 if (restore) { 110 return tick(); 111 } 112 }; 113 recalc(); 114 if (height === parent_height) { 115 return; 116 } 117 last_pos = void 0; 118 offset = offset_top; 119 recalc_counter = recalc_every; 120 tick = function() { 121 var css, delta, recalced, scroll, will_bottom, win_height; 122 if (detached) { 123 return; 124 } 125 recalced = false; 126 if (recalc_counter != null) { 127 recalc_counter -= 1; 128 if (recalc_counter <= 0) { 129 recalc_counter = recalc_every; 130 recalc(); 131 recalced = true; 132 } 133 } 134 if (!recalced && doc.height() !== last_scroll_height) { 135 recalc(); 136 recalced = true; 137 } 138 scroll = win.scrollTop(); 139 if (last_pos != null) { 140 delta = scroll - last_pos; 141 } 142 last_pos = scroll; 143 if (fixed) { 144 if (enable_bottoming) { 145 will_bottom = scroll + height + offset > parent_height + parent_top; 146 if (bottomed && !will_bottom) { 147 bottomed = false; 148 elm.css({ 149 position: "fixed", 150 bottom: "", 151 top: offset 152 }).trigger("sticky_kit:unbottom"); 153 } 154 } 155 if (scroll < top) { 156 fixed = false; 157 offset = offset_top; 158 if (manual_spacer == null) { 159 if (el_float === "left" || el_float === "right") { 160 elm.insertAfter(spacer); 161 } 162 spacer.detach(); 163 } 164 css = { 165 position: "", 166 width: "", 167 top: "" 168 }; 169 elm.css(css).removeClass(sticky_class).trigger("sticky_kit:unstick"); 170 } 171 if (inner_scrolling) { 172 win_height = win.height(); 173 if (height + offset_top > win_height) { 174 if (!bottomed) { 175 offset -= delta; 176 offset = Math.max(win_height - height, offset); 177 offset = Math.min(offset_top, offset); 178 if (fixed) { 179 elm.css({ 180 top: offset + "px" 181 }); 182 } 183 } 184 } 185 } 186 } else { 187 if (scroll > top) { 188 fixed = true; 189 css = { 190 position: "fixed", 191 top: offset 192 }; 193 css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px"; 194 elm.css(css).addClass(sticky_class); 195 if (manual_spacer == null) { 196 elm.after(spacer); 197 if (el_float === "left" || el_float === "right") { 198 spacer.append(elm); 199 } 200 } 201 elm.trigger("sticky_kit:stick"); 202 } 203 } 204 if (fixed && enable_bottoming) { 205 if (will_bottom == null) { 206 will_bottom = scroll + height + offset > parent_height + parent_top; 207 } 208 if (!bottomed && will_bottom) { 209 bottomed = true; 210 if (parent.css("position") === "static") { 211 parent.css({ 212 position: "relative" 213 }); 214 } 215 return elm.css({ 216 position: "absolute",
vendor: 1,420 bytes, lines 217-266
217 bottom: padding_bottom, 218 top: "auto" 219 }).trigger("sticky_kit:bottom"); 220 } 221 } 222 }; 223 recalc_and_tick = function() { 224 recalc(); 225 return tick(); 226 }; 227 detach = function() { 228 detached = true; 229 win.off("touchmove", tick); 230 win.off("scroll", tick); 231 win.off("resize", recalc_and_tick); 232 $(document.body).off("sticky_kit:recalc", recalc_and_tick); 233 elm.off("sticky_kit:detach", detach); 234 elm.removeData("sticky_kit"); 235 elm.css({ 236 position: "", 237 bottom: "", 238 top: "", 239 width: "" 240 }); 241 parent.position("position", ""); 242 if (fixed) { 243 if (manual_spacer == null) { 244 if (el_float === "left" || el_float === "right") { 245 elm.insertAfter(spacer); 246 } 247 spacer.remove(); 248 } 249 return elm.removeClass(sticky_class); 250 } 251 }; 252 win.on("touchmove", tick); 253 win.on("scroll", tick); 254 win.on("resize", recalc_and_tick); 255 $(document.body).on("sticky_kit:recalc", recalc_and_tick); 256 elm.on("sticky_kit:detach", detach); 257 return setTimeout(tick, 0); 258 }; 259 for (i = 0, len = this.length; i < len; i++) { 260 elm = this[i]; 261 fn($(elm)); 262 } 263 return this; 264 }; 265 266}).call(this);
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.