diff --git a/package.json b/package.json index bdfbb8a..0433ff0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-popup", - "version": "1.3.0", + "version": "1.4.0", "description": "", "main": "tp-popup.js", "scripts": { @@ -13,7 +13,7 @@ "author": "trading_peter", "license": "Apache-2.0", "dependencies": { - "@tp/helpers": "^2.0.0", + "@tp/helpers": "^2.13.0", "@tp/tp-icon": "^1.0.1", "lit": "^3.0.0" } diff --git a/tp-popup.js b/tp-popup.js index 0a1d0dc..def3fa0 100644 --- a/tp-popup.js +++ b/tp-popup.js @@ -89,7 +89,12 @@ class TpPopup extends EventHelpers(Position(DomQuery(LitElement))) { alwaysToggle: { type: Boolean, reflect: true }, halign: { type: String }, valign: { type: String }, - scrollTarget: { type: Object } + scrollTarget: { type: Object }, + // When true, clamp the popup against its containing-block rect instead + // of the viewport. Enable for popups under an ancestor with transform / + // filter / contain:layout|paint, where position: fixed resolves against + // that ancestor and the viewport is the wrong clamp edge. + clampToContainer: { type: Boolean, reflect: true } }; } @@ -100,6 +105,7 @@ class TpPopup extends EventHelpers(Position(DomQuery(LitElement))) { this.halign = 'middle'; this.valign = 'bottom'; this.scrollTarget = document; + this.clampToContainer = false; this.fit = this.fit.bind(this); this._onDocClickHandler = () => this.close(); } @@ -165,7 +171,8 @@ class TpPopup extends EventHelpers(Position(DomQuery(LitElement))) { this._posFixed(this.shadowRoot.querySelector('.toggle'), this.$.content, { valign: this.valign || 'bottom', halign: this.halign || 'middle', - spacing: 5 + spacing: 5, + clampToContainer: this.clampToContainer }); }