Skip to content

Commit

Permalink
Merge pull request foundation#10522 from SassNinja/feature/dropdown-p…
Browse files Browse the repository at this point in the history
…osition

Original dropdown position & alignment and CSS classes
  • Loading branch information
kball authored Aug 17, 2017
2 parents 95e4850 + 2dfd719 commit 191ee59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/foundation.dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class Dropdown extends Positionable {
* @private
*/
_setPosition() {
this.$element.removeClass(`has-position-${this.position} has-alignment-${this.alignment}`);
super._setPosition(this.$currentAnchor, this.$element, this.$parent);
this.$element.addClass(`has-position-${this.position} has-alignment-${this.alignment}`);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions js/foundation.positionable.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Positionable extends Plugin {
this.triedPositions = {};
this.position = this.options.position === 'auto' ? this._getDefaultPosition() : this.options.position;
this.alignment = this.options.alignment === 'auto' ? this._getDefaultAlignment() : this.options.alignment;
this.originalPosition = this.position;
this.originalAlignment = this.alignment;
}

_getDefaultPosition () {
Expand Down Expand Up @@ -122,6 +124,12 @@ class Positionable extends Plugin {
$anchorDims = Box.GetDimensions($anchor);


if (!this.options.allowOverlap) {
// restore original position & alignment before checking overlap
this.position = this.originalPosition;
this.alignment = this.originalAlignment;
}

$element.offset(Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));

if(!this.options.allowOverlap) {
Expand Down

0 comments on commit 191ee59

Please sign in to comment.