@glomex/glomex-dialog
Advanced tools
Comparing version 2.0.6 to 2.1.0
@@ -11,2 +11,3 @@ import { RotataToFullscreen } from './rotate-to-fullscreen.js'; | ||
const PHONE_MAX_WIDTH = 480; | ||
const STICKY_TOP_SELECTOR_THRESHOLD = 200; | ||
@@ -47,6 +48,8 @@ let allowRotateToFullscreen = false; | ||
const dockTarget = element.getAttribute('dock-target'); | ||
let dockTargetElement; | ||
let dockTargetElements; | ||
if (dockTarget) { | ||
dockTargetElement = document.querySelector(dockTarget); | ||
if (!dockTargetElement) return null; | ||
dockTargetElements = document.querySelectorAll(dockTarget); | ||
if (dockTargetElements.length === 0) return null; | ||
// pick the innermost node (querySelectorAll sorts by order in DOM) | ||
const dockTargetElement = dockTargetElements[dockTargetElements.length - 1]; | ||
const intersection = getViewportIntersection(dockTargetElement); | ||
@@ -847,2 +850,18 @@ if (intersection && intersection.width > 0 && intersection.height > 0) { | ||
]; | ||
// adjust the ".dock-sticky-target" top value based on selector | ||
if (dockMode === 'sticky') { | ||
const alternativeDockTarget = getAlternativeDockTarget(this); | ||
if (alternativeDockTarget) { | ||
const { height } = getViewportIntersection(alternativeDockTarget); | ||
// in case we attach to navigation bars that can be expanded | ||
// we ignore to adjust sticky position below a certain threshold | ||
// based on given external selector | ||
if (height < STICKY_TOP_SELECTOR_THRESHOLD) { | ||
// add 5px to have some distance from the top | ||
const adjustedHeight = height + 5; | ||
dockStickyTarget.style.top = `${adjustedHeight || 0}px`; | ||
} | ||
} | ||
} | ||
const moveTo = dockMode === 'sticky' | ||
@@ -849,0 +868,0 @@ ? getDockStickyTarget(this) |
{ | ||
"name": "@glomex/glomex-dialog", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"description": "A dialog web component that allows docking a video player or putting it in a lightbox", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121599
1214