vendor: 24,018 bytes, lines 1-663
1/*! 2 * Stellar.js v0.6.2 3 * http://markdalgleish.com/projects/stellar.js 4 * 5 * Copyright 2014, Mark Dalgleish 6 * This content is released under the MIT license 7 * http://markdalgleish.mit-license.org 8 */ 9 10;(function($, window, document, undefined) { 11 12 var pluginName = 'stellar', 13 defaults = { 14 scrollProperty: 'scroll', 15 positionProperty: 'position', 16 horizontalScrolling: true, 17 verticalScrolling: true, 18 horizontalOffset: 0, 19 verticalOffset: 0, 20 responsive: false, 21 parallaxBackgrounds: true, 22 parallaxElements: true, 23 hideDistantElements: true, 24 hideElement: function($elem) { $elem.hide(); }, 25 showElement: function($elem) { $elem.show(); } 26 }, 27 28 scrollProperty = { 29 scroll: { 30 getLeft: function($elem) { return $elem.scrollLeft(); }, 31 setLeft: function($elem, val) { $elem.scrollLeft(val); }, 32 33 getTop: function($elem) { return $elem.scrollTop(); }, 34 setTop: function($elem, val) { $elem.scrollTop(val); } 35 }, 36 position: { 37 getLeft: function($elem) { return parseInt($elem.css('left'), 10) * -1; }, 38 getTop: function($elem) { return parseInt($elem.css('top'), 10) * -1; } 39 }, 40 margin: { 41 getLeft: function($elem) { return parseInt($elem.css('margin-left'), 10) * -1; }, 42 getTop: function($elem) { return parseInt($elem.css('margin-top'), 10) * -1; } 43 }, 44 transform: { 45 getLeft: function($elem) { 46 var computedTransform = getComputedStyle($elem[0])[prefixedTransform]; 47 return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[4], 10) * -1 : 0); 48 }, 49 getTop: function($elem) { 50 var computedTransform = getComputedStyle($elem[0])[prefixedTransform]; 51 return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[5], 10) * -1 : 0); 52 } 53 } 54 }, 55 56 positionProperty = { 57 position: { 58 setLeft: function($elem, left) { $elem.css('left', left); }, 59 setTop: function($elem, top) { $elem.css('top', top); } 60 }, 61 transform: { 62 setPosition: function($elem, left, startingLeft, top, startingTop) { 63 $elem[0].style[prefixedTransform] = 'translate3d(' + (left - startingLeft) + 'px, ' + (top - startingTop) + 'px, 0)'; 64 } 65 } 66 }, 67 68 // Returns a function which adds a vendor prefix to any CSS property name 69 vendorPrefix = (function() { 70 var prefixes = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/, 71 style = $('script')[0].style, 72 prefix = '', 73 prop; 74 75 for (prop in style) { 76 if (prefixes.test(prop)) { 77 prefix = prop.match(prefixes)[0]; 78 break; 79 } 80 } 81 82 if ('WebkitOpacity' in style) { prefix = 'Webkit'; } 83 if ('KhtmlOpacity' in style) { prefix = 'Khtml'; } 84 85 return function(property) { 86 return prefix + (prefix.length > 0 ? property.charAt(0).toUpperCase() + property.slice(1) : property); 87 }; 88 }()), 89 90 prefixedTransform = vendorPrefix('transform'), 91 92 supportsBackgroundPositionXY = $('<div />', { style: 'background:#fff' }).css('background-position-x') !== undefined, 93 94 setBackgroundPosition = (supportsBackgroundPositionXY ? 95 function($elem, x, y) { 96 $elem.css({ 97 'background-position-x': x, 98 'background-position-y': y 99 }); 100 } : 101 function($elem, x, y) { 102 $elem.css('background-position', x + ' ' + y); 103 } 104 ), 105 106 getBackgroundPosition = (supportsBackgroundPositionXY ? 107 function($elem) { 108 return [ 109 $elem.css('background-position-x'), 110 $elem.css('background-position-y') 111 ]; 112 } : 113 function($elem) { 114 return $elem.css('background-position').split(' '); 115 } 116 ), 117 118 requestAnimFrame = ( 119 window.requestAnimationFrame || 120 window.webkitRequestAnimationFrame || 121 window.mozRequestAnimationFrame || 122 window.oRequestAnimationFrame || 123 window.msRequestAnimationFrame || 124 function(callback) { 125 setTimeout(callback, 1000 / 60); 126 } 127 ); 128 129 function Plugin(element, options) { 130 this.element = element; 131 this.options = $.extend({}, defaults, options); 132 133 this._defaults = defaults; 134 this._name = pluginName; 135 136 this.init(); 137 } 138 139 Plugin.prototype = { 140 init: function() { 141 this.options.name = pluginName + '_' + Math.floor(Math.random() * 1e9); 142 143 this._defineElements(); 144 this._defineGetters(); 145 this._defineSetters(); 146 this._handleWindowLoadAndResize(); 147 this._detectViewport(); 148 149 this.refresh({ firstLoad: true }); 150 151 if (this.options.scrollProperty === 'scroll') { 152 this._handleScrollEvent(); 153 } else { 154 this._startAnimationLoop(); 155 } 156 }, 157 _defineElements: function() { 158 if (this.element === document.body) this.element = window; 159 this.$scrollElement = $(this.element); 160 this.$element = (this.element === window ? $('body') : this.$scrollElement); 161 this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window || this.options.scrollProperty === 'scroll' ? this.$scrollElement : this.$scrollElement.parent()) ); 162 }, 163 _defineGetters: function() { 164 var self = this, 165 scrollPropertyAdapter = scrollProperty[self.options.scrollProperty]; 166 167 this._getScrollLeft = function() { 168 return scrollPropertyAdapter.getLeft(self.$scrollElement); 169 }; 170 171 this._getScrollTop = function() { 172 return scrollPropertyAdapter.getTop(self.$scrollElement); 173 }; 174 }, 175 _defineSetters: function() { 176 var self = this, 177 scrollPropertyAdapter = scrollProperty[self.options.scrollProperty], 178 positionPropertyAdapter = positionProperty[self.options.positionProperty], 179 setScrollLeft = scrollPropertyAdapter.setLeft, 180 setScrollTop = scrollPropertyAdapter.setTop; 181 182 this._setScrollLeft = (typeof setScrollLeft === 'function' ? function(val) { 183 setScrollLeft(self.$scrollElement, val); 184 } : $.noop); 185 186 this._setScrollTop = (typeof setScrollTop === 'function' ? function(val) { 187 setScrollTop(self.$scrollElement, val); 188 } : $.noop); 189 190 this._setPosition = positionPropertyAdapter.setPosition || 191 function($elem, left, startingLeft, top, startingTop) { 192 if (self.options.horizontalScrolling) { 193 positionPropertyAdapter.setLeft($elem, left, startingLeft); 194 } 195 196 if (self.options.verticalScrolling) { 197 positionPropertyAdapter.setTop($elem, top, startingTop); 198 } 199 }; 200 }, 201 _handleWindowLoadAndResize: function() { 202 var self = this, 203 $window = $(window); 204 205 if (self.options.responsive) { 206 $window.bind('load.' + this.name, function() { 207 self.refresh(); 208 }); 209 } 210 211 $window.bind('resize.' + this.name, function() { 212 self._detectViewport(); 213 214 if (self.options.responsive) { 215 self.refresh(); 216 } 217 }); 218 }, 219 refresh: function(options) { 220 var self = this, 221 oldLeft = self._getScrollLeft(), 222 oldTop = self._getScrollTop(); 223 224 if (!options || !options.firstLoad) { 225 this._reset(); 226 } 227 228 this._setScrollLeft(0); 229 this._setScrollTop(0); 230 231 this._setOffsets(); 232 this._findParticles(); 233 this._findBackgrounds(); 234 235 // Fix for WebKit background rendering bug 236 if (options && options.firstLoad && /WebKit/.test(navigator.userAgent)) { 237 $(window).on("load",function () { 238 var oldLeft = self._getScrollLeft(), 239 oldTop = self._getScrollTop(); 240 241 self._setScrollLeft(oldLeft + 1); 242 self._setScrollTop(oldTop + 1); 243 244 self._setScrollLeft(oldLeft); 245 self._setScrollTop(oldTop); 246 }); 247 } 248 249 this._setScrollLeft(oldLeft); 250 this._setScrollTop(oldTop); 251 }, 252 _detectViewport: function() { 253 var viewportOffsets = { 254 left: this.$viewportElement.scrollLeft(), 255 top: this.$viewportElement.scrollTop() 256 }; 257 var hasOffsets = viewportOffsets !== null && viewportOffsets !== undefined; 258 259 this.viewportWidth = this.$viewportElement.width(); 260 this.viewportHeight = this.$viewportElement.height(); 261 262 this.viewportOffsetTop = (hasOffsets ? viewportOffsets.top : 0); 263 this.viewportOffsetLeft = (hasOffsets ? viewportOffsets.left : 0); 264 }, 265 _findParticles: function() { 266 var self = this, 267 scrollLeft = this._getScrollLeft(), 268 scrollTop = this._getScrollTop(); 269 270 if (this.particles !== undefined) { 271 for (var i = this.particles.length - 1; i >= 0; i--) { 272 this.particles[i].$element.data('stellar-elementIsActive', undefined); 273 } 274 } 275 276 this.particles = []; 277 278 if (!this.options.parallaxElements) return; 279 280 this.$element.find('[data-stellar-ratio]').each(function(i) { 281 var $this = $(this), 282 horizontalOffset, 283 verticalOffset, 284 positionLeft, 285 positionTop, 286 marginLeft, 287 marginTop, 288 $offsetParent, 289 offsetLeft, 290 offsetTop, 291 parentOffsetLeft = 0, 292 parentOffsetTop = 0, 293 tempParentOffsetLeft = 0, 294 tempParentOffsetTop = 0; 295 296 // Ensure this element isn't already part of another scrolling element 297 if (!$this.data('stellar-elementIsActive')) { 298 $this.data('stellar-elementIsActive', this); 299 } else if ($this.data('stellar-elementIsActive') !== this) { 300 return; 301 } 302 303 self.options.showElement($this); 304 305 // Save/restore the original top and left CSS values in case we refresh the particles or destroy the instance 306 if (!$this.data('stellar-startingLeft')) { 307 $this.data('stellar-startingLeft', $this.css('left')); 308 $this.data('stellar-startingTop', $this.css('top')); 309 } else { 310 $this.css('left', $this.data('stellar-startingLeft')); 311 $this.css('top', $this.data('stellar-startingTop')); 312 } 313 314 positionLeft = $this.position().left; 315 positionTop = $this.position().top; 316 317 // Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8) 318 marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10); 319 marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10); 320 321 offsetLeft = $this.offset().left - marginLeft; 322 offsetTop = $this.offset().top - marginTop; 323 324 // Calculate the offset parent 325 $this.parents().each(function() { 326 var $this = $(this); 327 328 if ($this.data('stellar-offset-parent') === true) { 329 parentOffsetLeft = tempParentOffsetLeft; 330 parentOffsetTop = tempParentOffsetTop; 331 $offsetParent = $this; 332 333 return false; 334 } else { 335 tempParentOffsetLeft += $this.position().left; 336 tempParentOffsetTop += $this.position().top; 337 } 338 }); 339 340 // Detect the offsets 341 horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset)); 342 verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset)); 343 344 // Add our object to the particles collection 345 self.particles.push({ 346 $element: $this, 347 $offsetParent: $offsetParent, 348 isFixed: $this.css('position') === 'fixed', 349 horizontalOffset: horizontalOffset, 350 verticalOffset: verticalOffset, 351 startingPositionLeft: positionLeft, 352 startingPositionTop: positionTop, 353 startingOffsetLeft: offsetLeft, 354 startingOffsetTop: offsetTop, 355 parentOffsetLeft: parentOffsetLeft, 356 parentOffsetTop: parentOffsetTop, 357 stellarRatio: ($this.data('stellar-ratio') !== undefined ? $this.data('stellar-ratio') : 1), 358 width: $this.outerWidth(true), 359 height: $this.outerHeight(true), 360 isHidden: false 361 }); 362 }); 363 }, 364 _findBackgrounds: function() { 365 var self = this, 366 scrollLeft = this._getScrollLeft(), 367 scrollTop = this._getScrollTop(), 368 $backgroundElements; 369 370 this.backgrounds = []; 371 372 if (!this.options.parallaxBackgrounds) return; 373 374 $backgroundElements = this.$element.find('[data-stellar-background-ratio]'); 375 376 if (this.$element.data('stellar-background-ratio')) { 377 $backgroundElements = $backgroundElements.add(this.$element); 378 } 379 380 $backgroundElements.each(function() { 381 var $this = $(this), 382 backgroundPosition = getBackgroundPosition($this), 383 horizontalOffset, 384 verticalOffset, 385 positionLeft, 386 positionTop, 387 marginLeft, 388 marginTop, 389 offsetLeft, 390 offsetTop, 391 $offsetParent, 392 parentOffsetLeft = 0, 393 parentOffsetTop = 0, 394 tempParentOffsetLeft = 0, 395 tempParentOffsetTop = 0; 396 397 // Ensure this element isn't already part of another scrolling element 398 if (!$this.data('stellar-backgroundIsActive')) { 399 $this.data('stellar-backgroundIsActive', this); 400 } else if ($this.data('stellar-backgroundIsActive') !== this) { 401 return; 402 } 403 404 // Save/restore the original top and left CSS values in case we destroy the instance 405 if (!$this.data('stellar-backgroundStartingLeft')) { 406 $this.data('stellar-backgroundStartingLeft', backgroundPosition[0]); 407 $this.data('stellar-backgroundStartingTop', backgroundPosition[1]); 408 } else { 409 setBackgroundPosition($this, $this.data('stellar-backgroundStartingLeft'), $this.data('stellar-backgroundStartingTop')); 410 } 411 412 // Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8) 413 marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10); 414 marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10); 415 416 offsetLeft = $this.offset().left - marginLeft - scrollLeft; 417 offsetTop = $this.offset().top - marginTop - scrollTop; 418 419 // Calculate the offset parent 420 $this.parents().each(function() { 421 var $this = $(this); 422 423 if ($this.data('stellar-offset-parent') === true) { 424 parentOffsetLeft = tempParentOffsetLeft; 425 parentOffsetTop = tempParentOffsetTop; 426 $offsetParent = $this; 427 428 return false; 429 } else { 430 tempParentOffsetLeft += $this.position().left; 431 tempParentOffsetTop += $this.position().top; 432 } 433 }); 434 435 // Detect the offsets 436 horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset)); 437 verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset)); 438 439 self.backgrounds.push({ 440 $element: $this, 441 $offsetParent: $offsetParent, 442 isFixed: $this.css('background-attachment') === 'fixed', 443 horizontalOffset: horizontalOffset, 444 verticalOffset: verticalOffset, 445 startingValueLeft: backgroundPosition[0], 446 startingValueTop: backgroundPosition[1], 447 startingBackgroundPositionLeft: (isNaN(parseInt(backgroundPosition[0], 10)) ? 0 : parseInt(backgroundPosition[0], 10)), 448 startingBackgroundPositionTop: (isNaN(parseInt(backgroundPosition[1], 10)) ? 0 : parseInt(backgroundPosition[1], 10)), 449 startingPositionLeft: $this.position().left, 450 startingPositionTop: $this.position().top, 451 startingOffsetLeft: offsetLeft, 452 startingOffsetTop: offsetTop, 453 parentOffsetLeft: parentOffsetLeft, 454 parentOffsetTop: parentOffsetTop, 455 stellarRatio: ($this.data('stellar-background-ratio') === undefined ? 1 : $this.data('stellar-background-ratio')) 456 }); 457 }); 458 }, 459 _reset: function() { 460 var particle, 461 startingPositionLeft, 462 startingPositionTop, 463 background, 464 i; 465 466 for (i = this.particles.length - 1; i >= 0; i--) { 467 particle = this.particles[i]; 468 startingPositionLeft = particle.$element.data('stellar-startingLeft'); 469 startingPositionTop = particle.$element.data('stellar-startingTop'); 470 471 this._setPosition(particle.$element, startingPositionLeft, startingPositionLeft, startingPositionTop, startingPositionTop); 472 473 this.options.showElement(particle.$element); 474 475 particle.$element.data('stellar-startingLeft', null).data('stellar-elementIsActive', null).data('stellar-backgroundIsActive', null); 476 } 477 478 for (i = this.backgrounds.length - 1; i >= 0; i--) { 479 background = this.backgrounds[i]; 480 481 background.$element.data('stellar-backgroundStartingLeft', null).data('stellar-backgroundStartingTop', null); 482 483 setBackgroundPosition(background.$element, background.startingValueLeft, background.startingValueTop); 484 } 485 }, 486 destroy: function() { 487 this._reset(); 488 489 this.$scrollElement.unbind('resize.' + this.name).unbind('scroll.' + this.name); 490 this._animationLoop = $.noop; 491 492 $(window).unbind('load.' + this.name).unbind('resize.' + this.name); 493 }, 494 _setOffsets: function() { 495 var self = this, 496 $window = $(window); 497 498 $window.unbind('resize.horizontal-' + this.name).unbind('resize.vertical-' + this.name); 499 500 if (typeof this.options.horizontalOffset === 'function') { 501 this.horizontalOffset = this.options.horizontalOffset(); 502 $window.bind('resize.horizontal-' + this.name, function() { 503 self.horizontalOffset = self.options.horizontalOffset(); 504 }); 505 } else { 506 this.horizontalOffset = this.options.horizontalOffset; 507 } 508 509 if (typeof this.options.verticalOffset === 'function') { 510 this.verticalOffset = this.options.verticalOffset(); 511 $window.bind('resize.vertical-' + this.name, function() { 512 self.verticalOffset = self.options.verticalOffset(); 513 }); 514 } else { 515 this.verticalOffset = this.options.verticalOffset; 516 } 517 }, 518 _repositionElements: function() { 519 var scrollLeft = this._getScrollLeft(), 520 scrollTop = this._getScrollTop(), 521 horizontalOffset, 522 verticalOffset, 523 particle, 524 fixedRatioOffset, 525 background, 526 bgLeft, 527 bgTop, 528 isVisibleVertical = true, 529 isVisibleHorizontal = true, 530 newPositionLeft, 531 newPositionTop, 532 newOffsetLeft, 533 newOffsetTop, 534 i; 535 536 // First check that the scroll position or container size has changed 537 if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) { 538 return; 539 } else { 540 this.currentScrollLeft = scrollLeft; 541 this.currentScrollTop = scrollTop; 542 this.currentWidth = this.viewportWidth; 543 this.currentHeight = this.viewportHeight; 544 } 545 546 // Reposition elements 547 for (i = this.particles.length - 1; i >= 0; i--) { 548 particle = this.particles[i]; 549 550 fixedRatioOffset = (particle.isFixed ? 1 : 0); 551 552 // Calculate position, then calculate what the particle's new offset will be (for visibility check) 553 if (this.options.horizontalScrolling) { 554 newPositionLeft = (scrollLeft + particle.horizontalOffset + this.viewportOffsetLeft + particle.startingPositionLeft - particle.startingOffsetLeft + particle.parentOffsetLeft) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionLeft; 555 newOffsetLeft = newPositionLeft - particle.startingPositionLeft + particle.startingOffsetLeft; 556 } else { 557 newPositionLeft = particle.startingPositionLeft; 558 newOffsetLeft = particle.startingOffsetLeft; 559 } 560 561 if (this.options.verticalScrolling) { 562 newPositionTop = (scrollTop + particle.verticalOffset + this.viewportOffsetTop + particle.startingPositionTop - particle.startingOffsetTop + particle.parentOffsetTop) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionTop; 563 newOffsetTop = newPositionTop - particle.startingPositionTop + particle.startingOffsetTop; 564 } else { 565 newPositionTop = particle.startingPositionTop; 566 newOffsetTop = particle.startingOffsetTop; 567 } 568 569 // Check visibility 570 if (this.options.hideDistantElements) { 571 isVisibleHorizontal = !this.options.horizontalScrolling || newOffsetLeft + particle.width > (particle.isFixed ? 0 : scrollLeft) && newOffsetLeft < (particle.isFixed ? 0 : scrollLeft) + this.viewportWidth + this.viewportOffsetLeft; 572 isVisibleVertical = !this.options.verticalScrolling || newOffsetTop + particle.height > (particle.isFixed ? 0 : scrollTop) && newOffsetTop < (particle.isFixed ? 0 : scrollTop) + this.viewportHeight + this.viewportOffsetTop; 573 } 574 575 if (isVisibleHorizontal && isVisibleVertical) { 576 if (particle.isHidden) { 577 this.options.showElement(particle.$element); 578 particle.isHidden = false; 579 } 580 581 this._setPosition(particle.$element, newPositionLeft, particle.startingPositionLeft, newPositionTop, particle.startingPositionTop); 582 } else { 583 if (!particle.isHidden) { 584 this.options.hideElement(particle.$element); 585 particle.isHidden = true; 586 } 587 } 588 } 589 590 // Reposition backgrounds 591 for (i = this.backgrounds.length - 1; i >= 0; i--) { 592 background = this.backgrounds[i]; 593 594 fixedRatioOffset = (background.isFixed ? 0 : 1); 595 bgLeft = (this.options.horizontalScrolling ? (scrollLeft + background.horizontalOffset - this.viewportOffsetLeft - background.startingOffsetLeft + background.parentOffsetLeft - background.startingBackgroundPositionLeft) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueLeft); 596 bgTop = (this.options.verticalScrolling ? (scrollTop + background.verticalOffset - this.viewportOffsetTop - background.startingOffsetTop + background.parentOffsetTop - background.startingBackgroundPositionTop) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueTop); 597 598 setBackgroundPosition(background.$element, bgLeft, bgTop); 599 } 600 }, 601 _handleScrollEvent: function() { 602 var self = this, 603 ticking = false; 604 605 var update = function() { 606 self._repositionElements(); 607 ticking = false; 608 }; 609 610 var requestTick = function() { 611 if (!ticking) { 612 requestAnimFrame(update); 613 ticking = true; 614 } 615 }; 616 617 this.$scrollElement.bind('scroll.' + this.name, requestTick); 618 requestTick(); 619 }, 620 _startAnimationLoop: function() { 621 var self = this; 622 623 this._animationLoop = function() { 624 requestAnimFrame(self._animationLoop); 625 self._repositionElements(); 626 }; 627 this._animationLoop(); 628 } 629 }; 630 631 $.fn[pluginName] = function (options) { 632 var args = arguments; 633 if (options === undefined || typeof options === 'object') { 634 return this.each(function () { 635 if (!$.data(this, 'plugin_' + pluginName)) { 636 $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 637 } 638 }); 639 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 640 return this.each(function () { 641 var instance = $.data(this, 'plugin_' + pluginName); 642 if (instance instanceof Plugin && typeof instance[options] === 'function') { 643 instance[options].apply(instance, Array.prototype.slice.call(args, 1)); 644 } 645 if (options === 'destroy') { 646 $.data(this, 'plugin_' + pluginName, null); 647 } 648 }); 649 } 650 }; 651 652 $[pluginName] = function(options) { 653 var $window = $(window); 654 return $window.stellar.apply($window, Array.prototype.slice.call(arguments, 0)); 655 }; 656 657 // Expose the scroll and position property function hashes so they can be extended 658 $[pluginName].scrollProperty = scrollProperty; 659 $[pluginName].positionProperty = positionProperty; 660 661 // Expose the plugin class so it can be modified 662 window.Stellar = Plugin; 663}(jQuery, this, document));
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.