audero-sticky
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "audero-sticky", | ||
"version": "0.1.0", | ||
"description": "Audero Sticky is a polyfill for the CSS position: sticky with no dependencies and support for multiple module systems." | ||
"version": "0.1.1", | ||
"description": "Audero Sticky is a polyfill for the CSS position: sticky with no dependencies and support for multiple module systems.", | ||
"main": "src/audero-sticky.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -1,3 +0,3 @@ | ||
/*! audero-sticky.js 0.1.0 | Aurelio De Rosa (@AurelioDeRosa) | MIT/GPL-3.0 Licensed */ | ||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.Sticky=b()}(this,function(){"use strict";function a(a,b,c){var d=document.createEvent("Event");d.initEvent(b,!0,!0);for(var e in c)c.hasOwnProperty(e)&&(d[e]=c[e]);a.dispatchEvent(d)}function b(a,b){b.forEach(function(b){a[b]=""})}function c(a,b,c){c||(c=Object.keys(b)),c.forEach(function(c){a[c]=b[c]})}function d(a,b){var c=[].slice.call(document.querySelectorAll(b));return c.indexOf(a)+1}function e(a){var b={};for(var c in a)b[c]=a[c]+"px";return b}function f(a){b(a.element.style,m.concat(["marginTop","marginBottom"])),a.element.style.position=a._position,a._placeholder&&a._placeholder.parentNode&&a._placeholder.parentNode.removeChild(a._placeholder)}function g(a){var b={},c=window.getComputedStyle(a.element);return"auto"!==c.top?(b.start=a.element.getBoundingClientRect().top-parseFloat(c.top),b.end=a.element.parentNode.getBoundingClientRect().bottom):(b.start=a.element.getBoundingClientRect().bottom+parseFloat(c.bottom),b.end=a.element.parentNode.getBoundingClientRect().top),b.start+=window.pageYOffset,b.end+=window.pageYOffset,b}function h(b){function d(){b._position=b.element.style.position,c(b.element.style,{position:"fixed",marginTop:0,marginBottom:0}),c(b.element.style,b._placeholder.style,m),b.element.parentNode.insertBefore(b._placeholder,b.element),j=!0,a(b.element,"stickystart")}function e(){f(b),j=!1,a(b.element,"stickyend")}function h(){var a=parseFloat(window.getComputedStyle(b.element).height)||0,c=k.end-a-window.pageYOffset,f=window.pageYOffset>=k.start&&window.pageYOffset<=k.end;f?(j||d(),b.element.style.top=c-n>=0?"":c+"px"):j&&e()}function i(){var a=parseFloat(window.getComputedStyle(b.element).height)||0,c=window.pageYOffset+window.innerHeight,f=k.end+a-c,g=c<=k.start&&c>=k.end;g?(j||d(),b.element.style.bottom=0>=f+n?"":-f+"px"):j&&e()}var j=!1,k=g(b),l=window.getComputedStyle(b.element),n="auto"!==l.top?parseFloat(l.top):parseFloat(l.bottom);return"auto"!==l.top?h:i}function i(a){return function(){window.removeEventListener("resize",a._handlers.resize),a.destroy(),a.init(),a._handlers.scroll()}}function j(a){window.addEventListener("load",a._handlers.scroll),window.addEventListener("scroll",a._handlers.scroll),window.addEventListener("resize",a._handlers.resize)}function k(a,b){this.element=a,this.settings=b||l,this._placeholder=null,this._position="",this._handlers={}}var l={selector:".sticky"},m=["width","height","left","marginLeft","marginRight","zIndex"];return k.isFeatureSupported=function(){var a=document.createElement("div");return a.style.cssText="position:sticky",!!a.style.position},k.autoInit=function(a){a=a||l,[].forEach.call(document.querySelectorAll(a.selector),function(a){var b=new k(a);b.init()})},k.prototype.init=function(){var a=this.element.getBoundingClientRect();this._placeholder=document.createElement("div"),this._handlers.scroll=h(this),this._handlers.resize=i(this),this._placeholder.style.zIndex=d(this.element,this.settings.selector),c(this._placeholder.style,window.getComputedStyle(this.element),["top","bottom","marginTop","marginBottom","marginLeft","marginRight"]),c(this._placeholder.style,e(a),["width","height","left"]),j(this)},k.prototype.destroy=function(){f(this),window.removeEventListener("scroll",this._handlers.scroll),window.removeEventListener("resize",this._handlers.resize),this._handlers={},this._position="",this._placeholder=null},k}); | ||
/*! audero-sticky.js 0.1.1 | Aurelio De Rosa (@AurelioDeRosa) | MIT/GPL-3.0 Licensed */ | ||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.Sticky=b()}(this,function(){"use strict";function a(a,b,c){var d=document.createEvent("Event");d.initEvent(b,!0,!0);for(var e in c)c.hasOwnProperty(e)&&(d[e]=c[e]);a.dispatchEvent(d)}function b(a,b){b.forEach(function(b){a[b]=""})}function c(a,b,c){c||(c=Object.keys(b)),c.forEach(function(c){a[c]=b[c]})}function d(a,b){var c=[].slice.call(document.querySelectorAll(b));return c.indexOf(a)+1}function e(a){var b={};for(var c in a)b[c]=a[c]+"px";return b}function f(a){b(a.element.style,m.concat(["marginTop","marginBottom"])),a.element.style.position=a._position,a._placeholder&&a._placeholder.parentNode&&a._placeholder.parentNode.removeChild(a._placeholder)}function g(a){var b={},c=window.getComputedStyle(a.element);return"auto"!==c.top?(b.start=a.element.getBoundingClientRect().top-parseFloat(c.top),b.end=a.element.parentNode.getBoundingClientRect().bottom):(b.start=a.element.getBoundingClientRect().bottom+parseFloat(c.bottom),b.end=a.element.parentNode.getBoundingClientRect().top),b.start+=window.pageYOffset,b.end+=window.pageYOffset,b}function h(b){function d(){b._position=b.element.style.position,c(b.element.style,{position:"fixed",marginTop:0,marginBottom:0}),c(b.element.style,b._placeholder.style,m),b.element.parentNode.insertBefore(b._placeholder,b.element),j=!0,a(b.element,"stickystart")}function e(){f(b),j=!1,a(b.element,"stickyend")}function h(){var a=parseFloat(window.getComputedStyle(b.element).height)||0,c=g(b),f=c.end-a-window.pageYOffset,h=window.pageYOffset>=c.start&&window.pageYOffset<=c.end;h?(j||d(),b.element.style.top=f-l>=0?"":f+"px"):j&&e()}function i(){var a=parseFloat(window.getComputedStyle(b.element).height)||0,c=g(b),f=window.pageYOffset+window.innerHeight,h=c.end+a-f,i=f<=c.start&&f>=c.end;i?(j||d(),b.element.style.bottom=0>=h+l?"":-h+"px"):j&&e()}var j=!1,k=window.getComputedStyle(b.element),l="auto"!==k.top?parseFloat(k.top):parseFloat(k.bottom);return"auto"!==k.top?h:i}function i(a){return function(){window.removeEventListener("resize",a._handlers.resize),a.destroy(),a.init(),a._handlers.scroll()}}function j(a){window.addEventListener("load",a._handlers.scroll),window.addEventListener("scroll",a._handlers.scroll),window.addEventListener("resize",a._handlers.resize)}function k(a,b){this.element=a,this.settings=b||l,this._placeholder=null,this._position="",this._handlers={}}var l={selector:".sticky"},m=["width","height","left","marginLeft","marginRight","zIndex"];return k.isFeatureSupported=function(){var a=document.createElement("div");return a.style.cssText="position:sticky",!!a.style.position},k.autoInit=function(a){a=a||l,[].forEach.call(document.querySelectorAll(a.selector),function(b){var c=new k(b,a);c.init()})},k.prototype.init=function(){var a=this.element.getBoundingClientRect();this._placeholder=document.createElement("div"),this._handlers.scroll=h(this),this._handlers.resize=i(this),this._placeholder.style.zIndex=d(this.element,this.settings.selector),c(this._placeholder.style,window.getComputedStyle(this.element),["top","bottom","marginTop","marginBottom","marginLeft","marginRight"]),c(this._placeholder.style,e(a),["width","height","left"]),j(this)},k.prototype.destroy=function(){f(this),window.removeEventListener("scroll",this._handlers.scroll),window.removeEventListener("resize",this._handlers.resize),this._handlers={},this._position="",this._placeholder=null},k}); | ||
//# sourceMappingURL=audero-sticky.min.js.map |
{ | ||
"name": "audero-sticky", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Audero Sticky is a polyfill for the CSS position: sticky with no dependencies and support for multiple module systems.", | ||
@@ -5,0 +5,0 @@ "main": "src/audero-sticky.js", |
@@ -116,3 +116,3 @@ # Audero Sticky | ||
### `Sticky.autoinit([options])` | ||
### `Sticky.autoInit([options])` | ||
@@ -199,3 +199,3 @@ Autoinitializes all the elements of the page having class `sticky` if no options are provided. Otherwise, it | ||
Sticky.autoInit({ | ||
selector: 'fixedsticky' | ||
selector: '.fixedsticky' | ||
}); | ||
@@ -202,0 +202,0 @@ } |
@@ -190,3 +190,2 @@ (function(root, factory) { | ||
var isAdded = false; | ||
var boundaries = calculateBoundaries(sticky); | ||
var elementStyle = window.getComputedStyle(sticky.element); | ||
@@ -221,2 +220,3 @@ var distanceFromSide = elementStyle.top !== 'auto' ? | ||
var height = parseFloat(window.getComputedStyle(sticky.element).height) || 0; | ||
var boundaries = calculateBoundaries(sticky); | ||
var gap = boundaries.end - height - window.pageYOffset; | ||
@@ -238,2 +238,3 @@ var isInRange = window.pageYOffset >= boundaries.start && window.pageYOffset <= boundaries.end; | ||
var height = parseFloat(window.getComputedStyle(sticky.element).height) || 0; | ||
var boundaries = calculateBoundaries(sticky); | ||
var windowBottom = window.pageYOffset + window.innerHeight; | ||
@@ -327,3 +328,3 @@ var gap = boundaries.end + height - windowBottom; | ||
function(element) { | ||
var sticky = new Sticky(element); | ||
var sticky = new Sticky(element, options); | ||
@@ -330,0 +331,0 @@ sticky.init(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65139
443