1/* 2 * HC-Sticky 3 * ========= 4 * Version: 2.2.7 5 * Author: Some Web Media 6 * Author URL: https://github.com/somewebmedia 7 * Plugin URL: https://github.com/somewebmedia/hc-sticky 8 * Description: JavaScript library that makes any element on your page visible while you scroll 9 * License: MIT 10 */ 11'use strict'; 12! ( function ( t, e ) { 13 if ( 'object' == typeof module && 'object' == typeof module.exports ) { 14 if ( ! t.document ) 15 throw new Error( 'HC-Sticky requires a browser to run.' ); 16 module.exports = e( t ); 17 } else 18 'function' == typeof define && define.amd 19 ? define( 'hcSticky', [], e( t ) ) 20 : e( t ); 21} )( 'undefined' != typeof window ? window : this, function ( V ) { 22 var i, 23 n, 24 Q = V.document, 25 U = { 26 top: 0, 27 bottom: 0, 28 bottomEnd: 0, 29 innerTop: 0, 30 innerSticker: null, 31 stickyClass: 'sticky', 32 stickTo: null, 33 followScroll: ! 0, 34 responsive: null, 35 mobileFirst: ! 1, 36 onStart: null, 37 onStop: null, 38 onBeforeResize: null, 39 onResize: null, 40 resizeDebounce: 100, 41 disable: ! 1, 42 }, 43 Y = function ( t, e, o ) { 44 console.warn( 45 '%cHC Sticky:%c ' + 46 o + 47 "%c '" + 48 t + 49 "'%c is now deprecated and will be removed. Use%c '" + 50 e + 51 "'%c instead.", 52 'color: #fa253b', 53 'color: default', 54 'color: #5595c6', 55 'color: default', 56 'color: #5595c6', 57 'color: default' 58 ); 59 }, 60 $ = function ( n, f ) { 61 var o = this; 62 if ( 63 ( ( f = f || {} ), 64 ! ( n = 'string' == typeof n ? Q.querySelector( n ) : n ) ) 65 ) 66 return ! 1; 67 f.queries && Y( 'queries', 'responsive', 'option' ), 68 f.queryFlow && Y( 'queryFlow', 'mobileFirst', 'option' ); 69 var p = {}, 70 u = $.Helpers, 71 s = n.parentNode; 72 'static' === u.getStyle( s, 'position' ) && 73 ( s.style.position = 'relative' ); 74 function d( t ) { 75 ( u.isEmptyObject( ( t = t || {} ) ) && 76 ! u.isEmptyObject( p ) ) || 77 ( p = Object.assign( {}, U, p, t ) ); 78 } 79 function t() { 80 return p.disable; 81 } 82 function e() { 83 var t, 84 e = p.responsive || p.queries; 85 if ( e ) { 86 var o = V.innerWidth; 87 if ( 88 ( ( t = f ), 89 ( p = Object.assign( {}, U, t || {} ) ).mobileFirst ) 90 ) 91 for ( var i in e ) 92 i <= o && 93 ! u.isEmptyObject( e[ i ] ) && 94 d( e[ i ] ); 95 else { 96 var n, 97 s = []; 98 for ( n in e ) { 99 var r = {}; 100 ( r[ n ] = e[ n ] ), s.push( r ); 101 } 102 for ( var l = s.length - 1; 0 <= l; l-- ) { 103 var a = s[ l ], 104 c = Object.keys( a )[ 0 ]; 105 o <= c && 106 ! u.isEmptyObject( a[ c ] ) && 107 d( a[ c ] ); 108 } 109 } 110 } 111 } 112 function i() { 113 var t, e, o, i; 114 ( I.css = 115 ( ( t = n ), 116 ( e = u.getCascadedStyle( t ) ), 117 ( o = u.getStyle( t ) ), 118 ( i = { 119 height: t.offsetHeight + 'px', 120 left: e.left, 121 right: e.right, 122 top: e.top, 123 bottom: e.bottom, 124 position: o.position, 125 display: o.display, 126 verticalAlign: o.verticalAlign, 127 boxSizing: o.boxSizing, 128 marginLeft: e.marginLeft, 129 marginRight: e.marginRight, 130 marginTop: e.marginTop, 131 marginBottom: e.marginBottom, 132 paddingLeft: e.paddingLeft, 133 paddingRight: e.paddingRight, 134 } ), 135 e.float && ( i.float = e.float || 'none' ), 136 e.cssFloat && ( i.cssFloat = e.cssFloat || 'none' ), 137 o.MozBoxSizing && ( i.MozBoxSizing = o.MozBoxSizing ), 138 ( i.width = 139 'auto' !== e.width 140 ? e.width 141 : 'border-box' === i.boxSizing || 142 'border-box' === i.MozBoxSizing 143 ? t.offsetWidth + 'px' 144 : o.width ), 145 i ) ), 146 P.init(), 147 ( y = ! ( 148 ! p.stickTo || 149 ! ( 150 'document' === p.stickTo || 151 ( p.stickTo.nodeType && 152 9 === p.stickTo.nodeType ) || 153 ( 'object' == typeof p.stickTo && 154 p.stickTo instanceof 155 ( 'undefined' != typeof HTMLDocument 156 ? HTMLDocument 157 : Document ) ) 158 ) 159 ) ), 160 ( h = p.stickTo 161 ? y 162 ? Q 163 : u.getElement( p.stickTo ) 164 : s ), 165 ( z = ( R = function () { 166 var t = 167 n.offsetHeight + 168 ( parseInt( I.css.marginTop ) || 0 ) + 169 ( parseInt( I.css.marginBottom ) || 0 ), 170 e = ( z || 0 ) - t; 171 return -1 <= e && e <= 1 ? z : t; 172 } )() ), 173 ( v = ( H = function () { 174 return y 175 ? Math.max( 176 Q.documentElement.clientHeight, 177 Q.body.scrollHeight, 178 Q.documentElement.scrollHeight, 179 Q.body.offsetHeight, 180 Q.documentElement.offsetHeight 181 ) 182 : h.offsetHeight; 183 } )() ), 184 ( S = y ? 0 : u.offset( h ).top ), 185 ( w = p.stickTo ? ( y ? 0 : u.offset( s ).top ) : S ), 186 ( E = V.innerHeight ), 187 ( N = n.offsetTop - ( parseInt( I.css.marginTop ) || 0 ) ), 188 ( b = u.getElement( p.innerSticker ) ), 189 ( L = 190 isNaN( p.top ) && -1 < p.top.indexOf( '%' ) 191 ? ( parseFloat( p.top ) / 100 ) * E 192 : p.top ), 193 ( k = 194 isNaN( p.bottom ) && -1 < p.bottom.indexOf( '%' ) 195 ? ( parseFloat( p.bottom ) / 100 ) * E 196 : p.bottom ), 197 ( x = b ? b.offsetTop : p.innerTop || 0 ), 198 ( T = 199 isNaN( p.bottomEnd ) && -1 < p.bottomEnd.indexOf( '%' ) 200 ? ( parseFloat( p.bottomEnd ) / 100 ) * E 201 : p.bottomEnd ), 202 ( j = S - L + x + N ); 203 } 204 function r() { 205 ( z = R() ), ( v = H() ), ( O = S + v - L - T ), ( C = E < z ); 206 var t, 207 e = V.pageYOffset || Q.documentElement.scrollTop, 208 o = u.offset( n ).top, 209 i = o - e; 210 ( B = e < F ? 'up' : 'down' ), 211 ( A = e - F ), 212 j < ( F = e ) 213 ? O + 214 L + 215 ( C ? k : 0 ) - 216 ( p.followScroll && C ? 0 : L ) <= 217 e + 218 z - 219 x - 220 ( E - ( j - x ) < z - x && 221 p.followScroll && 222 0 < ( t = z - E - x ) 223 ? t 224 : 0 ) 225 ? I.release( { 226 position: 'absolute', 227 bottom: w + s.offsetHeight - O - L, 228 } ) 229 : C && p.followScroll 230 ? 'down' == B 231 ? i + z + k <= E + 0.9 232 ? I.stick( {bottom: k} ) 233 : 'fixed' === I.position && 234 I.release( { 235 position: 'absolute', 236 top: o - L - j - A + x, 237 } )
238 : Math.ceil( i + x ) < 0 && 239 'fixed' === I.position 240 ? I.release( { 241 position: 'absolute', 242 top: o - L - j + x - A, 243 } ) 244 : e + L - x <= o && I.stick( {top: L - x} ) 245 : I.stick( {top: L - x} ) 246 : I.release( {stop: ! 0} ); 247 } 248 function l() { 249 M && 250 ( V.removeEventListener( 'scroll', r, u.supportsPassive ), 251 ( M = ! 1 ) ); 252 } 253 function a() { 254 null !== n.offsetParent && 'none' !== u.getStyle( n, 'display' ) 255 ? ( i(), 256 v < z 257 ? l() 258 : ( r(), 259 M || 260 ( V.addEventListener( 261 'scroll', 262 r, 263 u.supportsPassive 264 ), 265 ( M = ! 0 ) ) ) ) 266 : l(); 267 } 268 function c() { 269 ( n.style.position = '' ), 270 ( n.style.left = '' ), 271 ( n.style.top = '' ), 272 ( n.style.bottom = '' ), 273 ( n.style.width = '' ), 274 n.classList 275 ? n.classList.remove( p.stickyClass ) 276 : ( n.className = n.className.replace( 277 new RegExp( 278 '(^|\\b)' + 279 p.stickyClass.split( ' ' ).join( '|' ) + 280 '(\\b|$)', 281 'gi' 282 ), 283 ' ' 284 ) ), 285 ( I.css = {} ), 286 ! ( I.position = null ) === P.isAttached && P.detach(); 287 } 288 function g() { 289 c(), e(), ( t() ? l : a )(); 290 } 291 function m() { 292 q && 293 ( V.removeEventListener( 'resize', W, u.supportsPassive ), 294 ( q = ! 1 ) ), 295 l(); 296 } 297 var y, 298 h, 299 b, 300 v, 301 S, 302 w, 303 E, 304 L, 305 k, 306 x, 307 T, 308 j, 309 O, 310 C, 311 z, 312 N, 313 H, 314 R, 315 A, 316 B, 317 I = { 318 css: {}, 319 position: null, 320 stick: function ( t ) { 321 ( t = t || {} ), 322 u.hasClass( n, p.stickyClass ) || 323 ( ! 1 === P.isAttached && P.attach(), 324 ( I.position = 'fixed' ), 325 ( n.style.position = 'fixed' ), 326 ( n.style.left = P.offsetLeft + 'px' ), 327 ( n.style.width = P.width ), 328 void 0 === t.bottom 329 ? ( n.style.bottom = 'auto' ) 330 : ( n.style.bottom = t.bottom + 'px' ), 331 void 0 === t.top 332 ? ( n.style.top = 'auto' ) 333 : ( n.style.top = t.top + 'px' ), 334 n.classList 335 ? n.classList.add( p.stickyClass ) 336 : ( n.className += ' ' + p.stickyClass ), 337 p.onStart && 338 p.onStart.call( 339 n, 340 Object.assign( {}, p ) 341 ) ); 342 }, 343 release: function ( t ) { 344 var e; 345 ( ( t = t || {} ).stop = t.stop || ! 1 ), 346 ( ! 0 !== t.stop && 347 'fixed' !== I.position && 348 null !== I.position && 349 ( ( void 0 === t.top && void 0 === t.bottom ) || 350 ( void 0 !== t.top && 351 ( parseInt( u.getStyle( n, 'top' ) ) || 352 0 ) === t.top ) || 353 ( void 0 !== t.bottom && 354 ( parseInt( 355 u.getStyle( n, 'bottom' ) 356 ) || 0 ) === t.bottom ) ) ) || 357 ( ! 0 === t.stop 358 ? ! 0 === P.isAttached && P.detach() 359 : ! 1 === P.isAttached && P.attach(), 360 ( e = t.position || I.css.position ), 361 ( I.position = e ), 362 ( n.style.position = e ), 363 ( n.style.left = 364 ! 0 === t.stop 365 ? I.css.left 366 : P.positionLeft + 'px' ), 367 ( n.style.width = ( 368 'absolute' !== e ? I.css : P 369 ).width ), 370 void 0 === t.bottom 371 ? ( n.style.bottom = 372 ! 0 === t.stop ? '' : 'auto' ) 373 : ( n.style.bottom = t.bottom + 'px' ), 374 void 0 === t.top 375 ? ( n.style.top = 376 ! 0 === t.stop ? '' : 'auto' ) 377 : ( n.style.top = t.top + 'px' ), 378 n.classList 379 ? n.classList.remove( p.stickyClass ) 380 : ( n.className = n.className.replace( 381 new RegExp( 382 '(^|\\b)' + 383 p.stickyClass 384 .split( ' ' ) 385 .join( '|' ) + 386 '(\\b|$)', 387 'gi' 388 ), 389 ' ' 390 ) ), 391 p.onStop && 392 p.onStop.call( 393 n, 394 Object.assign( {}, p ) 395 ) ); 396 }, 397 }, 398 P = { 399 el: Q.createElement( 'div' ), 400 offsetLeft: null, 401 positionLeft: null, 402 width: null, 403 isAttached: ! 1, 404 init: function () { 405 for ( var t in ( ( P.el.className = 'sticky-spacer' ), 406 I.css ) ) 407 P.el.style[ t ] = I.css[ t ];
408 P.el.style[ 'z-index' ] = '-1'; 409 var e = u.getStyle( n ); 410 ( P.offsetLeft = 411 u.offset( n ).left - 412 ( parseInt( e.marginLeft ) || 0 ) ), 413 ( P.positionLeft = u.position( n ).left ), 414 ( P.width = u.getStyle( n, 'width' ) ); 415 }, 416 attach: function () { 417 s.insertBefore( P.el, n ), ( P.isAttached = ! 0 ); 418 }, 419 detach: function () { 420 ( P.el = s.removeChild( P.el ) ), 421 ( P.isAttached = ! 1 ); 422 }, 423 }, 424 F = V.pageYOffset || Q.documentElement.scrollTop, 425 M = ! 1, 426 q = ! 1, 427 D = function () { 428 p.onBeforeResize && 429 p.onBeforeResize.call( n, Object.assign( {}, p ) ), 430 g(), 431 p.onResize && 432 p.onResize.call( n, Object.assign( {}, p ) ); 433 }, 434 W = p.resizeDebounce ? u.debounce( D, p.resizeDebounce ) : D, 435 D = function () { 436 q || 437 ( V.addEventListener( 'resize', W, u.supportsPassive ), 438 ( q = ! 0 ) ), 439 e(), 440 ( t() ? l : a )(); 441 }; 442 ( this.options = function ( t ) { 443 return t ? p[ t ] : Object.assign( {}, p ); 444 } ), 445 ( this.refresh = g ), 446 ( this.update = function ( t ) { 447 d( t ), ( f = Object.assign( {}, f, t || {} ) ), g(); 448 } ), 449 ( this.attach = D ), 450 ( this.detach = m ), 451 ( this.destroy = function () { 452 m(), c(); 453 } ), 454 ( this.triggerMethod = function ( t, e ) { 455 'function' == typeof o[ t ] && o[ t ]( e ); 456 } ), 457 ( this.reinit = function () { 458 Y( 'reinit', 'refresh', 'method' ), g(); 459 } ), 460 d( f ), 461 D(), 462 V.addEventListener( 'load', g ); 463 }; 464 return ( 465 void 0 !== V.jQuery && 466 ( ( i = V.jQuery ), 467 ( n = 'hcSticky' ), 468 i.fn.extend( { 469 hcSticky: function ( e, o ) { 470 return this.length 471 ? 'options' === e 472 ? i.data( this.get( 0 ), n ).options() 473 : this.each( function () { 474 var t = i.data( this, n ); 475 t 476 ? t.triggerMethod( e, o ) 477 : ( ( t = new $( this, e ) ), 478 i.data( this, n, t ) ); 479 } ) 480 : this; 481 }, 482 } ) ), 483 ( V.hcSticky = V.hcSticky || $ ), 484 $ 485 ); 486} ), 487 ( function ( a ) { 488 var t = a.hcSticky, 489 c = a.document; 490 'function' != typeof Object.assign && 491 Object.defineProperty( Object, 'assign', { 492 value: function ( t, e ) { 493 if ( null == t ) 494 throw new TypeError( 495 'Cannot convert undefined or null to object' 496 ); 497 for ( 498 var o = Object( t ), i = 1; 499 i < arguments.length; 500 i++ 501 ) { 502 var n = arguments[ i ]; 503 if ( null != n ) 504 for ( var s in n ) 505 Object.prototype.hasOwnProperty.call( n, s ) && 506 ( o[ s ] = n[ s ] ); 507 } 508 return o; 509 }, 510 writable: ! 0, 511 configurable: ! 0, 512 } ), 513 Array.prototype.forEach || 514 ( Array.prototype.forEach = function ( t ) { 515 var e, o; 516 if ( null == this ) 517 throw new TypeError( 'this is null or not defined' ); 518 var i, 519 n = Object( this ), 520 s = n.length >>> 0; 521 if ( 'function' != typeof t ) 522 throw new TypeError( t + ' is not a function' ); 523 for ( 524 1 < arguments.length && ( e = arguments[ 1 ] ), o = 0; 525 o < s; 526 527 ) 528 o in n && ( ( i = n[ o ] ), t.call( e, i, o, n ) ), o++; 529 } ); 530 var e = ! 1; 531 try { 532 var o = Object.defineProperty( {}, 'passive', { 533 get: function () { 534 e = {passive: ! 1}; 535 }, 536 } ); 537 a.addEventListener( 'testPassive', null, o ), 538 a.removeEventListener( 'testPassive', null, o ); 539 } catch ( t ) {} 540 function n( t, e ) { 541 return a.getComputedStyle 542 ? e 543 ? c.defaultView 544 .getComputedStyle( t, null ) 545 .getPropertyValue( e ) 546 : c.defaultView.getComputedStyle( t, null ) 547 : t.currentStyle 548 ? e 549 ? t.currentStyle[ 550 e.replace( /-\w/g, function ( t ) { 551 return t.toUpperCase().replace( '-', '' ); 552 } ) 553 ] 554 : t.currentStyle 555 : void 0; 556 } 557 function s( t ) { 558 var e = t.getBoundingClientRect(), 559 o = a.pageYOffset || c.documentElement.scrollTop, 560 t = a.pageXOffset || c.documentElement.scrollLeft; 561 return {top: e.top + o, left: e.left + t}; 562 } 563 t.Helpers = { 564 supportsPassive: e, 565 isEmptyObject: function ( t ) { 566 for ( var e in t ) return ! 1; 567 return ! 0; 568 }, 569 debounce: function ( i, n, s ) { 570 var r; 571 return function () { 572 var t = this, 573 e = arguments, 574 o = s && ! r; 575 clearTimeout( r ), 576 ( r = setTimeout( function () { 577 ( r = null ), s || i.apply( t, e ); 578 }, n ) ), 579 o && i.apply( t, e ); 580 }; 581 }, 582 hasClass: function ( t, e ) { 583 return t.classList 584 ? t.classList.contains( e ) 585 : new RegExp( '(^| )' + e + '( |$)', 'gi' ).test( 586 t.className 587 ); 588 }, 589 offset: s, 590 position: function ( t ) { 591 var e = t.offsetParent, 592 o = s( e ), 593 i = s( t ), 594 e = n( e ), 595 t = n( t ); 596 return ( 597 ( o.top += parseInt( e.borderTopWidth ) || 0 ), 598 ( o.left += parseInt( e.borderLeftWidth ) || 0 ), 599 { 600 top: i.top - o.top - ( parseInt( t.marginTop ) || 0 ), 601 left: 602 i.left - o.left - ( parseInt( t.marginLeft ) || 0 ), 603 } 604 ); 605 }, 606 getElement: function ( t ) { 607 var e = null; 608 return ( 609 'string' == typeof t 610 ? ( e = c.querySelector( t ) ) 611 : a.jQuery && t instanceof a.jQuery && t.length 612 ? ( e = t[ 0 ] ) 613 : t instanceof Element && ( e = t ), 614 e 615 ); 616 }, 617 getStyle: n, 618 getCascadedStyle: function ( t ) { 619 var e, 620 o = t.cloneNode( ! 0 ); 621 ( o.style.display = 'none' ), 622 Array.prototype.slice 623 .call( o.querySelectorAll( 'input[type="radio"]' ) ) 624 .forEach( function ( t ) {
625 t.removeAttribute( 'name' ); 626 } ), 627 t.parentNode.insertBefore( o, t.nextSibling ), 628 o.currentStyle 629 ? ( e = o.currentStyle ) 630 : a.getComputedStyle && 631 ( e = c.defaultView.getComputedStyle( o, null ) ); 632 var i, 633 n, 634 s, 635 r = {}; 636 for ( i in e ) 637 ! isNaN( i ) || 638 ( 'string' != typeof e[ i ] && 639 'number' != typeof e[ i ] ) || 640 ( r[ i ] = e[ i ] ); 641 if ( Object.keys( r ).length < 3 ) 642 for ( var l in ( ( r = {} ), e ) ) 643 isNaN( l ) || 644 ( r[ 645 e[ l ].replace( /-\w/g, function ( t ) { 646 return t.toUpperCase().replace( '-', '' ); 647 } ) 648 ] = e.getPropertyValue( e[ l ] ) ); 649 return ( 650 r.margin || 'auto' !== r.marginLeft 651 ? r.margin || 652 r.marginLeft !== r.marginRight || 653 r.marginLeft !== r.marginTop || 654 r.marginLeft !== r.marginBottom || 655 ( r.margin = r.marginLeft ) 656 : ( r.margin = 'auto' ), 657 r.margin || 658 '0px' !== r.marginLeft || 659 '0px' !== r.marginRight || 660 ( ( s = 661 ( n = t.offsetLeft - t.parentNode.offsetLeft ) - 662 ( parseInt( r.left ) || 0 ) - 663 ( parseInt( r.right ) || 0 ) ), 664 ( 0 != 665 ( s = 666 t.parentNode.offsetWidth - 667 t.offsetWidth - 668 n - 669 ( parseInt( r.right ) || 0 ) + 670 ( parseInt( r.left ) || 0 ) - 671 s ) && 672 1 != s ) || 673 ( r.margin = 'auto' ) ), 674 o.parentNode.removeChild( o ), 675 ( o = null ), 676 r 677 ); 678 }, 679 }; 680 } )( window );
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.