Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

fix(dock): align horizontal dock hover area and remove settings deactivation expansion

Deepender259ec30f27faba
diff --git a/edge-drop-translations/en.json b/edge-drop-translations/en.json
index c51dbbe..12c66b8 100644
--- a/edge-drop-translations/en.json
+++ b/edge-drop-translations/en.json
@@ -81,6 +81,8 @@
"top": "Top",
"center": "Center",
"bottom": "Bottom",
+ "left": "Left",
+ "right": "Right",
"triggerZone": "Trigger Zone",
"edgeLocationHintTitle": "Edge location hint",
"edgeLocationHintDesc": "Subtly illuminate beacon on screen edge when touching edge at wrong position",
diff --git a/shared/types.ts b/shared/types.ts
index a514d79..e21db96 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -168,8 +168,8 @@ export interface Settings {
verticalOffset: number
/** Horizontal offset fraction along screen edge when positioned at top/bottom (0 = left, 0.5 = center, 1 = right). Default: 0.5. */
horizontalOffset?: number
- /** Vertical alignment of the hover trigger strip relative to shelf ('top' | 'center' | 'bottom'). Default: 'center'. */
- triggerAlignment?: 'top' | 'center' | 'bottom'
+ /** Vertical or horizontal alignment of the hover trigger strip relative to shelf ('top' | 'center' | 'bottom' | 'left' | 'right'). Default: 'center'. */
+ triggerAlignment?: 'top' | 'center' | 'bottom' | 'left' | 'right'
/** When true, subtly illuminates a beacon hint on the screen edge when touching the edge at a different position. Default: true. */
showEdgeLocationHint?: boolean
/** When true, plays tactile audio sound effects for sliders, buttons, and switches. Default: true. */
diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx
index bf8fe81..94ce8f0 100644
--- a/src/components/Panel.tsx
+++ b/src/components/Panel.tsx
@@ -307,8 +307,16 @@ export function Panel() {
settings.hotZoneHeight >= 0.55 ? 460 : settings.hotZoneHeight >= 0.35 ? 320 : 220
)
const halfTriggerW = triggerWidthPx / 2
- const insetLeft = `calc(50% - ${halfTriggerW}px)`
- const insetRight = `calc(50% - ${halfTriggerW}px)`
+ let insetLeft = `calc(50% - ${halfTriggerW}px)`
+ let insetRight = `calc(50% - ${halfTriggerW}px)`
+
+ if (alignment === 'top' || alignment === 'left') {
+ insetLeft = '0px'
+ insetRight = `calc(100% - ${triggerWidthPx}px)`
+ } else if (alignment === 'bottom' || alignment === 'right') {
+ insetLeft = `calc(100% - ${triggerWidthPx}px)`
+ insetRight = '0px'
+ }
// Set clipPath via style (not animate) to avoid Framer Motion's broken
// calc() interpolation — CSS transitions handle it correctly.
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 2f4a1c4..8aa8432 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -1271,9 +1271,9 @@ export function Settings({
<div className="shelf-card-bottom">
<div className="setting-pills" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 5 }}>
{[
- { label: t('position.top'), val: 'top' as const },
+ { label: t('position.left') || 'Left', val: 'top' as const },
{ label: t('position.center'), val: 'center' as const },
- { label: t('position.bottom'), val: 'bottom' as const }
+ { label: t('position.right') || 'Right', val: 'bottom' as const }
].map((opt) => (
<button
key={opt.val}
@@ -2072,12 +2072,12 @@ export function Settings({
</div>
<div className="setting-pills">
{[
- { label: t('position.top'), val: 'top' as const },
+ { label: isHorizontal ? (t('position.left') || 'Left') : t('position.top'), val: 'top' as const },
{ label: t('position.center'), val: 'center' as const },
- { label: t('position.bottom'), val: 'bottom' as const }
+ { label: isHorizontal ? (t('position.right') || 'Right') : t('position.bottom'), val: 'bottom' as const }
].map((opt) => (
<button
- key={opt.label}
+ key={opt.val}
className={`pill ${(settings.triggerAlignment || 'center') === opt.val ? 'active' : ''}`}
onClick={() => {
playButtonClickSound()
diff --git a/src/hooks/useEdgeHover.ts b/src/hooks/useEdgeHover.ts
index ca78c44..4aeed5d 100644
--- a/src/hooks/useEdgeHover.ts
+++ b/src/hooks/useEdgeHover.ts
@@ -66,7 +66,12 @@ export function notifyPreviewClosedByUser(): void {
}, PREVIEW_CLOSE_STAY_MS)
}
-export function getHorizontalDockMetrics(displayWidth: number, horizontalOffset = 0.5, hotZoneHeight = 0.25) {
+export function getHorizontalDockMetrics(
+ displayWidth: number,
+ horizontalOffset = 0.5,
+ hotZoneHeight = 0.25,
+ triggerAlignment: 'top' | 'center' | 'bottom' | 'left' | 'right' = 'center'
+) {
const dockWidth = Math.min(displayWidth - 60, 1080)
const pad = displayWidth >= dockWidth + 60 ? 30 : 0
const minX = pad
@@ -79,8 +84,16 @@ export function getHorizontalDockMetrics(displayWidth: number, horizontalOffset
const triggerWidth = Math.round(
hotZoneHeight >= 0.55 ? 460 : hotZoneHeight >= 0.35 ? 320 : 220
)
- const triggerLeft = dockCenterX - triggerWidth / 2
- const triggerRight = dockCenterX + triggerWidth / 2
+ let triggerLeft = dockCenterX - triggerWidth / 2
+ let triggerRight = dockCenterX + triggerWidth / 2
+
+ if (triggerAlignment === 'top' || triggerAlignment === 'left') {
+ triggerLeft = dockX
+ triggerRight = dockX + triggerWidth
+ } else if (triggerAlignment === 'bottom' || triggerAlignment === 'right') {
+ triggerLeft = dockX + dockWidth - triggerWidth
+ triggerRight = dockX + dockWidth
+ }
return {
dockWidth,
@@ -153,7 +166,7 @@ export function useEdgeHover(): void {
// Horizontal dock bounds (for top/bottom) — calculated in DISPLAY coordinates
const dispW = displaySize.current.width
- const dockMetrics = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25)
+ const dockMetrics = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25, s.triggerAlignment || 'center')
const left = dockMetrics.triggerLeft
const right = dockMetrics.triggerRight
const midX = dockMetrics.dockCenterX
@@ -325,8 +338,8 @@ export function useEdgeHover(): void {
if (s.stickPosition === 'top') {
const dispW = displaySize.current.width
- const { dockWidth, dockX } = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25)
- const bladeHeight = state.settingsOpen ? 480 : 218
+ const { dockWidth, dockX } = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25, s.triggerAlignment || 'center')
+ const bladeHeight = 218
const inBlade = y >= -BUFFER_PX && y <= bladeHeight && x >= dockX - BUFFER_PX && x <= dockX + dockWidth + BUFFER_PX
if (inBlade) return true
if (hasFlyout && state.previewFlyoutRect && state.previewFlyoutRect.left !== undefined && state.previewFlyoutRect.right !== undefined) {
@@ -342,9 +355,9 @@ export function useEdgeHover(): void {
} else if (s.stickPosition === 'bottom') {
const dispW = displaySize.current.width
const dispH = displaySize.current.height
- const { dockWidth, dockX } = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25)
+ const { dockWidth, dockX } = getHorizontalDockMetrics(dispW, s.horizontalOffset ?? 0.5, s.hotZoneHeight ?? 0.25, s.triggerAlignment || 'center')
const distFromBottom = dispH - y
- const bladeHeight = state.settingsOpen ? 480 : 218
+ const bladeHeight = 218
const inBlade = distFromBottom >= -BUFFER_PX && distFromBottom <= bladeHeight && x >= dockX - BUFFER_PX && x <= dockX + dockWidth + BUFFER_PX
if (inBlade) return true
if (hasFlyout && state.previewFlyoutRect && state.previewFlyoutRect.left !== undefined && state.previewFlyoutRect.right !== undefined) {
@@ -425,10 +438,10 @@ export function useEdgeHover(): void {
switch (stickPosition) {
case 'top': {
const distFromTop = data.y
- const triggerDepth = Math.max(state.settings.hotZoneWidth || 3, TRIGGER_PX)
+ const triggerDepth = Math.max(state.settings.hotZoneWidth ?? 3, 1)
const inEdgeNear = distFromTop >= -BUFFER_PX && distFromTop <= (triggerDepth + 25)
const dispW = displayWidth || displaySize.current.width
- const { dockWidth, dockX, triggerLeft, triggerRight } = getHorizontalDockMetrics(dispW, state.settings.horizontalOffset ?? 0.5, state.settings.hotZoneHeight ?? 0.25)
+ const { dockWidth, dockX, triggerLeft, triggerRight } = getHorizontalDockMetrics(dispW, state.settings.horizontalOffset ?? 0.5, state.settings.hotZoneHeight ?? 0.25, state.settings.triggerAlignment || 'center')
const inZone = data.x >= triggerLeft && data.x <= triggerRight
if (!inEdgeNear) {
@@ -467,7 +480,7 @@ export function useEdgeHover(): void {
edge.setInteractive(true)
}
- const baseBladeH = state.settingsOpen ? 480 : 218
+ const baseBladeH = 218
const keepOpenDepth = baseBladeH
const startCloseDepth = baseBladeH + 40
const insideX = data.x >= dockX - BUFFER_PX && data.x <= dockX + dockWidth + BUFFER_PX
@@ -497,10 +510,10 @@ export function useEdgeHover(): void {
case 'bottom': {
const dispH = displayHeight || displaySize.current.height
const distFromBottom = dispH - data.y
- const triggerDepth = Math.max(state.settings.hotZoneWidth || 3, TRIGGER_PX)
+ const triggerDepth = Math.max(state.settings.hotZoneWidth ?? 3, 1)
const inEdgeNear = distFromBottom >= -BUFFER_PX && distFromBottom <= (triggerDepth + 25)
const dispW = displayWidth || displaySize.current.width
- const { dockWidth, dockX, triggerLeft, triggerRight } = getHorizontalDockMetrics(dispW, state.settings.horizontalOffset ?? 0.5, state.settings.hotZoneHeight ?? 0.25)
+ const { dockWidth, dockX, triggerLeft, triggerRight } = getHorizontalDockMetrics(dispW, state.settings.horizontalOffset ?? 0.5, state.settings.hotZoneHeight ?? 0.25, state.settings.triggerAlignment || 'center')
const inZone = data.x >= triggerLeft && data.x <= triggerRight
if (!inEdgeNear) {
@@ -539,7 +552,7 @@ export function useEdgeHover(): void {
edge.setInteractive(true)
}
- const baseBladeH = state.settingsOpen ? 480 : 218
+ const baseBladeH = 218
const keepOpenDepth = baseBladeH
const startCloseDepth = baseBladeH + 40
const insideX = data.x >= dockX - BUFFER_PX && data.x <= dockX + dockWidth + BUFFER_PX
diff --git a/tests/edgeRetention.test.ts b/tests/edgeRetention.test.ts
index 64fd97a..3efc78b 100644
--- a/tests/edgeRetention.test.ts
+++ b/tests/edgeRetention.test.ts
@@ -63,16 +63,17 @@ describe('Unified Open-State Retention Across All 4 Edges', () => {
expect(hoverSrc).toContain('state.resetPositionChangedTime()')
})
- it('verifies isInsideBlade checks edgeTransition and uses dynamic blade height for top and bottom', () => {
+ it('verifies isInsideBlade checks edgeTransition and uses consistent 218px blade height for top and bottom', () => {
const hoverSrc = read('src/hooks/useEdgeHover.ts')
expect(hoverSrc).toContain('if (state.sliderActive || state.edgeTransition?.active) return true')
- expect(hoverSrc).toContain('const bladeHeight = state.settingsOpen ? 480 : 218')
+ expect(hoverSrc).toContain('const bladeHeight = 218')
+ expect(hoverSrc).not.toContain('state.settingsOpen ? 480 : 218')
expect(hoverSrc).toContain('distFromBottom <= bladeHeight')
})
- it('verifies unsubCursorEdge includes dynamic blade height and 40px hysteresis for top and bottom', () => {
+ it('verifies unsubCursorEdge includes consistent 218px blade height and 40px hysteresis for top and bottom', () => {
const hoverSrc = read('src/hooks/useEdgeHover.ts')
- expect(hoverSrc).toContain('const baseBladeH = state.settingsOpen ? 480 : 218')
+ expect(hoverSrc).toContain('const baseBladeH = 218')
expect(hoverSrc).toContain('const keepOpenDepth = baseBladeH')
expect(hoverSrc).toContain('const startCloseDepth = baseBladeH + 40')
expect(hoverSrc).toContain('const outsideX = data.x < dockX - (BUFFER_PX + 40) || data.x > dockX + dockWidth + (BUFFER_PX + 40)')
diff --git a/tests/horizontalSettings.test.ts b/tests/horizontalSettings.test.ts
index 0af0183..98125d9 100644
--- a/tests/horizontalSettings.test.ts
+++ b/tests/horizontalSettings.test.ts
@@ -128,6 +128,44 @@ describe('Horizontal Card Shelf Settings Layout', () => {
expect(large.triggerWidth).toBe(460)
})
+ it('getHorizontalDockMetrics accurately positions triggerLeft and triggerRight based on triggerAlignment', async () => {
+ const { getHorizontalDockMetrics } = await import('../src/hooks/useEdgeHover')
+ const dispW = 1920
+
+ // Center alignment
+ const centerMetrics = getHorizontalDockMetrics(dispW, 0.5, 0.25, 'center')
+ expect(centerMetrics.triggerLeft).toBe(centerMetrics.dockCenterX - centerMetrics.triggerWidth / 2)
+ expect(centerMetrics.triggerRight).toBe(centerMetrics.dockCenterX + centerMetrics.triggerWidth / 2)
+
+ // Left alignment ('left' and legacy 'top')
+ const leftMetrics = getHorizontalDockMetrics(dispW, 0.5, 0.25, 'left')
+ expect(leftMetrics.triggerLeft).toBe(leftMetrics.dockX)
+ expect(leftMetrics.triggerRight).toBe(leftMetrics.dockX + leftMetrics.triggerWidth)
+
+ const topMetrics = getHorizontalDockMetrics(dispW, 0.5, 0.25, 'top')
+ expect(topMetrics.triggerLeft).toBe(topMetrics.dockX)
+ expect(topMetrics.triggerRight).toBe(topMetrics.dockX + topMetrics.triggerWidth)
+
+ // Right alignment ('right' and legacy 'bottom')
+ const rightMetrics = getHorizontalDockMetrics(dispW, 0.5, 0.25, 'right')
+ expect(rightMetrics.triggerLeft).toBe(rightMetrics.dockX + rightMetrics.dockWidth - rightMetrics.triggerWidth)
+ expect(rightMetrics.triggerRight).toBe(rightMetrics.dockX + rightMetrics.dockWidth)
+
+ const bottomMetrics = getHorizontalDockMetrics(dispW, 0.5, 0.25, 'bottom')
+ expect(bottomMetrics.triggerLeft).toBe(bottomMetrics.dockX + bottomMetrics.dockWidth - bottomMetrics.triggerWidth)
+ expect(bottomMetrics.triggerRight).toBe(bottomMetrics.dockX + bottomMetrics.dockWidth)
+ })
+
+ it('Panel.tsx calculates insetLeft and insetRight dynamically matching trigger alignment', () => {
+ const panelSrc = read('src/components/Panel.tsx')
+ expect(panelSrc).toContain("if (alignment === 'top' || alignment === 'left')")
+ expect(panelSrc).toContain("insetLeft = '0px'")
+ expect(panelSrc).toContain('insetRight = `calc(100% - ${triggerWidthPx}px)`')
+ expect(panelSrc).toContain("else if (alignment === 'bottom' || alignment === 'right')")
+ expect(panelSrc).toContain('insetLeft = `calc(100% - ${triggerWidthPx}px)`')
+ expect(panelSrc).toContain("insetRight = '0px'")
+ })
+
it('Horizontal shelf includes position offset slider, trigger alignment, panel height, and auto-updates', () => {
const src = read('src/components/Settings.tsx')
// Find the isHorizontal branch