]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Restore original position & alignment if no more overlap and set appropriate CSS... 10522/head
authorSassNinja <kai.falkowski@gmail.com>
Mon, 7 Aug 2017 23:01:33 +0000 (01:01 +0200)
committerSassNinja <kai.falkowski@gmail.com>
Mon, 7 Aug 2017 23:01:33 +0000 (01:01 +0200)
js/foundation.dropdown.js
js/foundation.positionable.js

index 47e52ac0b0aeee1b3deb6bc0fc2ea0528502b6e2..ed054feeceff92ad24f3205169c7fcc399b0cc4a 100644 (file)
@@ -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}`);
   }
 
   /**
index 04f7ee367190cc9e0a80e1eb5feee8eac41ab947..e410e5c14681f3602d0e1479e22915cdedc81499 100644 (file)
@@ -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 () {
@@ -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) {