From: TJ Higgins Date: Tue, 2 Aug 2016 21:45:13 +0000 (+0000) Subject: Reapply parent offset calculations X-Git-Tag: v6.3-rc1~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8389%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Reapply parent offset calculations --- diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index ae54feccc..1ce16995a 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -52,7 +52,7 @@ class Dropdown { }); if(this.options.parentClass){ - this.$parent = $('.' + this.options.parentClass); + this.$parent = this.$element.parents('.' + this.options.parentClass); }else{ this.$parent = null; } @@ -139,8 +139,18 @@ class Dropdown { offset = (param === 'height') ? this.options.vOffset : this.options.hOffset; if(($eleDims.width >= $eleDims.windowDims.width) || (!this.counter && !Foundation.Box.ImNotTouchingYou(this.$element, this.$parent))){ - this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$anchor, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({ - 'width': $eleDims.windowDims.width - (this.options.hOffset * 2), + var newWidth = $eleDims.windowDims.width, + parentHOffset = 0; + if(this.$parent){ + var $parentDims = Foundation.Box.GetDimensions(this.$parent), + parentHOffset = $parentDims.offset.left; + if ($parentDims.width < newWidth){ + newWidth = $parentDims.width; + } + } + + this.$element.offset(Foundation.Box.GetOffsets(this.$element, this.$anchor, 'center bottom', this.options.vOffset, this.options.hOffset + parentHOffset, true)).css({ + 'width': newWidth - (this.options.hOffset * 2), 'height': 'auto' }); this.classChanged = true;