diff --git a/lib/web/mage/sticky.js b/lib/web/mage/sticky.js index 13925ea4ea893..ed1a955509842 100644 --- a/lib/web/mage/sticky.js +++ b/lib/web/mage/sticky.js @@ -11,7 +11,8 @@ define([ $.widget('mage.sticky', { options: { - container: '' + container: '', + spacingTop: 0 }, /** @@ -42,6 +43,12 @@ define([ if( !isStatic && this.element.is(':visible') ) { offset = $(document).scrollTop() - this.parentOffset; + if (typeof this.options.spacingTop === 'function') { + offset += this.options.spacingTop(); + } else { + offset += this.options.spacingTop; + } + offset = Math.max( 0, Math.min( offset, this.maxOffset) ); this.element.css( 'top', offset );