@internetarchive/collection-browser 4.5.1 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,25 +216,25 @@ export class HoverPaneController {
216
216
  getTemplate() {
217
217
  this.hoverPaneProps = this.host.getHoverPaneProps();
218
218
  return this.shouldRenderHoverPane
219
- ? html `
220
- ${this.touchBackdropTemplate}
221
- <tile-hover-pane
222
- popover
223
- tabindex="-1"
224
- aria-describedby="tile-hover-pane-aria-description"
225
- .model=${this.hoverPaneProps?.model}
226
- .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}
227
- .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}
228
- .loggedIn=${this.hoverPaneProps?.loggedIn}
229
- .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}
230
- .sortParam=${this.hoverPaneProps?.sortParam}
231
- .collectionTitles=${this.hoverPaneProps?.collectionTitles}
232
- .mobileBreakpoint=${this.mobileBreakpoint}
233
- .currentWidth=${window.innerWidth}
234
- ></tile-hover-pane>
235
- <div id="tile-hover-pane-aria-description" class="sr-only">
236
- ${msg('Press Up Arrow to exit item detail preview')}
237
- </div>
219
+ ? html `
220
+ ${this.touchBackdropTemplate}
221
+ <tile-hover-pane
222
+ popover
223
+ tabindex="-1"
224
+ aria-describedby="tile-hover-pane-aria-description"
225
+ .model=${this.hoverPaneProps?.model}
226
+ .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}
227
+ .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}
228
+ .loggedIn=${this.hoverPaneProps?.loggedIn}
229
+ .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}
230
+ .sortParam=${this.hoverPaneProps?.sortParam}
231
+ .collectionTitles=${this.hoverPaneProps?.collectionTitles}
232
+ .mobileBreakpoint=${this.mobileBreakpoint}
233
+ .currentWidth=${window.innerWidth}
234
+ ></tile-hover-pane>
235
+ <div id="tile-hover-pane-aria-description" class="sr-only">
236
+ ${msg('Press Up Arrow to exit item detail preview')}
237
+ </div>
238
238
  `
239
239
  : nothing;
240
240
  }
@@ -259,15 +259,15 @@ export class HoverPaneController {
259
259
  */
260
260
  get touchBackdropTemplate() {
261
261
  return this.showTouchBackdrop
262
- ? html `<div
263
- id="touch-backdrop"
264
- @touchstart=${this.handleBackdropInteraction}
265
- @touchmove=${this.handleBackdropInteraction}
266
- @touchend=${this.handleBackdropInteraction}
267
- @touchcancel=${this.handleBackdropInteraction}
268
- @mouseenter=${(e) => e.stopPropagation()}
269
- @mousemove=${(e) => e.stopPropagation()}
270
- @mouseleave=${(e) => e.stopPropagation()}
262
+ ? html `<div
263
+ id="touch-backdrop"
264
+ @touchstart=${this.handleBackdropInteraction}
265
+ @touchmove=${this.handleBackdropInteraction}
266
+ @touchend=${this.handleBackdropInteraction}
267
+ @touchcancel=${this.handleBackdropInteraction}
268
+ @mouseenter=${(e) => e.stopPropagation()}
269
+ @mousemove=${(e) => e.stopPropagation()}
270
+ @mouseleave=${(e) => e.stopPropagation()}
271
271
  ></div>`
272
272
  : nothing;
273
273
  }
@@ -410,7 +410,9 @@ export class HoverPaneController {
410
410
  // as it might have been removed by the previous update.
411
411
  if (!this.hoverPane?.isConnected)
412
412
  return;
413
- this.hoverPane?.showPopover?.();
413
+ if (this.hoverPane && !this.hoverPane.matches(':popover-open')) {
414
+ this.hoverPane.showPopover?.();
415
+ }
414
416
  await new Promise(resolve => {
415
417
  // Pane sizes aren't accurate until next frame
416
418
  requestAnimationFrame(resolve);
@@ -1 +1 @@
1
- {"version":3,"file":"hover-pane-controller.js","sourceRoot":"","sources":["../../../../src/tiles/hover/hover-pane-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,EAEJ,OAAO,GAGR,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAoEpC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,GAA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AsB,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { SortParam } from '@internetarchive/search-service';\nimport {\n html,\n HTMLTemplateResult,\n nothing,\n ReactiveController,\n ReactiveControllerHost,\n} from 'lit';\nimport type { TileModel } from '../../models';\nimport type { CollectionTitles } from '../../data-source/models';\nimport { msg } from '@lit/localize';\n\ntype HoverPaneState = 'hidden' | 'shown' | 'fading-out';\n\n// the anchor point of the hover pane\n// can be either the mouse cursor or near the host element\n// in the case of mouse navigation, we want it to follow the cursor\n// in the case of keyboard navigation, we want it to appear near the host element\ntype HoverPanePositionAnchor = 'host' | 'cursor';\n\nexport interface HoverPaneProperties {\n model?: TileModel;\n baseNavigationUrl?: string;\n baseImageUrl?: string;\n loggedIn: boolean;\n suppressBlurring: boolean;\n sortParam: SortParam | null;\n collectionTitles?: CollectionTitles;\n}\n\nexport interface HoverPaneControllerOptions {\n offsetX?: number;\n offsetY?: number;\n enableLongPress?: boolean;\n showDelay?: number;\n hideDelay?: number;\n longPressDelay?: number;\n mobileBreakpoint?: number;\n}\n\n/** A common interface for providing a hover pane element. */\nexport interface HoverPaneProviderInterface {\n /** Returns the provider's currently rendered hover pane element. */\n getHoverPane(): HTMLElement | undefined;\n /** Returns properties that should be passed to the hover pane. */\n getHoverPaneProps(): HoverPaneProperties;\n /** When user has keyboard navigated out of more info, we want the host to get focus */\n acquireFocus(): void;\n /** When user has keyboard navigated out of more info, we want the host to lose focus */\n releaseFocus(): void;\n}\n\nexport interface ToggleHoverPaneOptions {\n coords: { x: number; y: number };\n enableTouchBackdrop?: boolean;\n}\n\n/**\n * An interface for interacting with hover pane controllers (e.g.,\n * to retrieve their current hover pane template).\n */\nexport interface HoverPaneControllerInterface extends ReactiveController {\n /**\n * Returns the hover pane template to render based on this controller's\n * current state. The returned template may be `nothing` if the hover\n * pane should not currently be rendered.\n */\n getTemplate(): HTMLTemplateResult | typeof nothing;\n\n /**\n * Requests to manually toggle the state of the hover pane.\n * If the hover pane is already shown, it will begin fading out and then\n * subsequently be hidden and removed. If the hover pane is already fading\n * out or hidden, it will fade back in and be shown.\n */\n toggleHoverPane(options: ToggleHoverPaneOptions): void;\n}\n\nconst clamp = (val: number, min = -Infinity, max = Infinity) =>\n Math.max(min, Math.min(val, max));\n\nexport class HoverPaneController implements HoverPaneControllerInterface {\n /**\n * The hover pane element attached to this controller's host.\n */\n private hoverPane?: HTMLElement;\n\n /**\n * The properties to be passed to the hover pane element\n */\n private hoverPaneProps?: HoverPaneProperties;\n\n /**\n * The breakpoint (in pixels) below which the mobile interface should be used.\n */\n private mobileBreakpoint?: number = 600;\n\n /**\n * The number of horizontal pixels the hover pane should be offset from the\n * pointer position.\n */\n private offsetX: number = -10;\n\n /**\n * The number of vertical pixels the hover pane should be offset from the\n * pointer position.\n */\n private offsetY: number = 15;\n\n /**\n * The delay between the mouse idling within the host element and when the hover\n * pane should begin fading in (in milliseconds).\n */\n private showDelay: number = 300;\n\n /**\n * The delay between when the mouse leaves the host element and when the hover\n * pane should begin fading out (in milliseconds).\n */\n private hideDelay: number = 100;\n\n /**\n * The delay between when a touch event begins on the host element and when the\n * hover pane should begin fading in (in milliseconds).\n */\n private longPressDelay: number = 600;\n\n /**\n * Whether long press interactions should cause the hover pane to appear (when\n * below the mobile breakpoint).\n */\n private enableLongPress: boolean = false;\n\n /**\n * Used to control the current state of this provider's hover pane.\n * - `'hidden'` => The hover pane is not present at all.\n * - `'shown'` => The hover pane is either fading in or fully visible.\n * - `'fading-out'` => The hover pane is fading out and about to be removed.\n */\n private hoverPaneState: HoverPaneState = 'hidden';\n\n /** The timer ID for showing the hover pane */\n private showTimer?: number;\n\n /** The timer ID for hiding the hover pane */\n private hideTimer?: number;\n\n /** The timer ID for recognizing a long press event */\n private longPressTimer?: number;\n\n /**\n * Whether the touch backdrop should currently be rendered irrespective of other touch\n * interactions being enabled.\n */\n private forceTouchBackdrop: boolean = false;\n\n /** A record of the last mouse position on the host element, for positioning the hover pane */\n private lastPointerClientPos = { x: 0, y: 0 };\n\n /**\n * A flag to track whether the host element is being clicked by a pointer device, so that we\n * don't trigger unnecessary keyboard focus behaviors on click. This is needed, e.g., to prevent\n * the hover pane from appearing immediately at its `host` positioning on click, which can\n * obstruct the host element itself (due to the ordering of events fired).\n */\n private clicking = false;\n\n constructor(\n /** The host element to which this controller should attach listeners */\n private readonly host: ReactiveControllerHost &\n HoverPaneProviderInterface &\n HTMLElement,\n /** Options for adjusting the hover pane behavior (offsets, delays, etc.) */\n options: HoverPaneControllerOptions = {},\n ) {\n this.mobileBreakpoint = options.mobileBreakpoint ?? this.mobileBreakpoint;\n this.offsetX = options.offsetX ?? this.offsetX;\n this.offsetY = options.offsetY ?? this.offsetY;\n this.showDelay = options.showDelay ?? this.showDelay;\n this.hideDelay = options.hideDelay ?? this.hideDelay;\n this.longPressDelay = options.longPressDelay ?? this.longPressDelay;\n this.enableLongPress = options.enableLongPress ?? this.enableLongPress;\n\n this.host.addController(this);\n }\n\n hostConnected(): void {\n this.attachListeners();\n }\n\n hostDisconnected(): void {\n this.detachListeners();\n }\n\n hostUpdated(): void {\n this.hoverPane = this.host.getHoverPane();\n this.hoverPaneProps = this.host.getHoverPaneProps();\n }\n\n /** @inheritdoc */\n getTemplate(): HTMLTemplateResult | typeof nothing {\n this.hoverPaneProps = this.host.getHoverPaneProps();\n\n return this.shouldRenderHoverPane\n ? html`\n ${this.touchBackdropTemplate}\n <tile-hover-pane\n popover\n tabindex=\"-1\"\n aria-describedby=\"tile-hover-pane-aria-description\"\n .model=${this.hoverPaneProps?.model}\n .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}\n .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}\n .loggedIn=${this.hoverPaneProps?.loggedIn}\n .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}\n .sortParam=${this.hoverPaneProps?.sortParam}\n .collectionTitles=${this.hoverPaneProps?.collectionTitles}\n .mobileBreakpoint=${this.mobileBreakpoint}\n .currentWidth=${window.innerWidth}\n ></tile-hover-pane>\n <div id=\"tile-hover-pane-aria-description\" class=\"sr-only\">\n ${msg('Press Up Arrow to exit item detail preview')}\n </div>\n `\n : nothing;\n }\n\n /** @inheritdoc */\n toggleHoverPane(options: ToggleHoverPaneOptions): void {\n if (this.hoverPaneState !== 'hidden') {\n this.fadeOutHoverPane();\n this.forceTouchBackdrop = false;\n } else {\n this.lastPointerClientPos = options.coords;\n this.forceTouchBackdrop = options.enableTouchBackdrop ?? false;\n this.showHoverPane();\n }\n }\n\n /**\n * Produces a template for the invisible touch capture backdrop that\n * is used to cancel the hover pane on touch devices. We want any\n * touch interaction on the backdrop to remove the hover pane, and\n * we don't want to bubble up mouse events that would otherwise\n * affect the state of the hover pane (e.g., fading it back in).\n */\n private get touchBackdropTemplate(): HTMLTemplateResult | typeof nothing {\n return this.showTouchBackdrop\n ? html`<div\n id=\"touch-backdrop\"\n @touchstart=${this.handleBackdropInteraction}\n @touchmove=${this.handleBackdropInteraction}\n @touchend=${this.handleBackdropInteraction}\n @touchcancel=${this.handleBackdropInteraction}\n @mouseenter=${(e: MouseEvent) => e.stopPropagation()}\n @mousemove=${(e: MouseEvent) => e.stopPropagation()}\n @mouseleave=${(e: MouseEvent) => e.stopPropagation()}\n ></div>`\n : nothing;\n }\n\n private get showTouchBackdrop(): boolean {\n return (\n (this.isTouchEnabled && this.enableLongPress) || this.forceTouchBackdrop\n );\n }\n\n /** Whether to use the mobile layout */\n private get isMobileView(): boolean {\n return !!this.mobileBreakpoint && window.innerWidth < this.mobileBreakpoint;\n }\n\n private get isHoverEnabled(): boolean {\n return window.matchMedia('(hover: hover)').matches;\n }\n\n private get isTouchEnabled(): boolean {\n return (\n 'ontouchstart' in window &&\n window.matchMedia('(any-pointer: coarse)').matches\n );\n }\n\n /** Whether this controller should currently render its hover pane. */\n private get shouldRenderHoverPane(): boolean {\n return this.hoverPaneState !== 'hidden';\n }\n\n /**\n * Returns the desired top/left offsets (in pixels) for this tile's hover pane.\n * The desired offsets balance positioning the hover pane under the primary pointer\n * while preventing it from flowing outside the viewport. The returned offsets are\n * relative to the viewport, intended to position the pane as a popover element.\n *\n * These offsets are only valid if the hover pane is already rendered with its\n * correct width and height. If the hover pane is not present, the returned offsets\n * will simply represent the current pointer position.\n */\n private makePaneDesiredOffsets(anchor: HoverPanePositionAnchor): {\n top: number;\n left: number;\n } {\n // Try to find offsets for the hover pane that:\n // (a) cause it to lie entirely within the viewport, and\n // (b) to the extent possible, minimize the distance between the\n // nearest corner of the hover pane and the mouse/host element position\n // (with some additional offsets applied after the fact).\n\n let [left, top] = [0, 0];\n switch (anchor) {\n case 'host':\n const hostRect = this.host.getBoundingClientRect();\n // slight inset from host top left corner\n left = hostRect.left + 20;\n top = hostRect.top + 30;\n break;\n case 'cursor':\n left = this.lastPointerClientPos.x;\n top = this.lastPointerClientPos.y;\n break;\n }\n\n // Flip the hover pane according to which quadrant of the viewport the coordinates are in.\n // (Similar to how Wikipedia's link hover panes work)\n const flipHorizontal = left > window.innerWidth / 2;\n const flipVertical = top > window.innerHeight / 2;\n\n const hoverPaneRect = this.hoverPane?.getBoundingClientRect();\n if (hoverPaneRect) {\n // If we need to flip the hover pane, do so by subtracting its width/height from left/top\n if (flipHorizontal) {\n left -= hoverPaneRect.width;\n }\n if (flipVertical) {\n top -= hoverPaneRect.height;\n }\n\n // Apply desired offsets from the target position\n left += (flipHorizontal ? -1 : 1) * this.offsetX;\n top += (flipVertical ? -1 : 1) * this.offsetY;\n\n // On mobile view, shunt the hover pane to avoid overflowing the viewport\n if (this.isMobileView) {\n left = clamp(left, 20, window.innerWidth - hoverPaneRect.width - 20);\n top = clamp(top, 20, window.innerHeight - hoverPaneRect.height - 20);\n }\n }\n\n left += window.scrollX;\n top += window.scrollY;\n\n return { left, top };\n }\n\n /**\n * Adds to the host element all the listeners necessary to make the\n * hover pane functional.\n */\n private attachListeners(): void {\n // keyboard navigation listeners\n this.host.addEventListener('focus', this.handleFocus);\n this.host.addEventListener('blur', this.handleBlur);\n this.host.addEventListener('pointerdown', this.handlePointerDown);\n this.host.addEventListener('keyup', this.handleKeyUp);\n this.host.addEventListener('keydown', this.handleKeyDown);\n\n if (this.isHoverEnabled) {\n this.host.addEventListener('mouseenter', this.handleMouseEnter);\n this.host.addEventListener('mousemove', this.handleMouseMove);\n this.host.addEventListener('mouseleave', this.handleMouseLeave);\n }\n\n if (this.isTouchEnabled && this.enableLongPress) {\n this.host.addEventListener('touchstart', this.handleTouchStart);\n this.host.addEventListener('touchmove', this.handleLongPressCancel);\n this.host.addEventListener('touchend', this.handleLongPressCancel);\n this.host.addEventListener('touchcancel', this.handleLongPressCancel);\n this.host.addEventListener('contextmenu', this.handleContextMenu);\n }\n }\n\n /**\n * Removes all the hover pane listeners from the host element.\n */\n private detachListeners(): void {\n this.host.removeEventListener('mouseenter', this.handleMouseEnter);\n this.host.removeEventListener('mousemove', this.handleMouseMove);\n this.host.removeEventListener('mouseleave', this.handleMouseLeave);\n this.host.removeEventListener('touchstart', this.handleTouchStart);\n this.host.removeEventListener('touchmove', this.handleLongPressCancel);\n this.host.removeEventListener('touchend', this.handleLongPressCancel);\n this.host.removeEventListener('touchcancel', this.handleLongPressCancel);\n this.host.removeEventListener('contextmenu', this.handleContextMenu);\n\n // keyboard navigation listeners\n this.host.removeEventListener('focus', this.handleFocus);\n this.host.removeEventListener('blur', this.handleBlur);\n this.host.removeEventListener('keyup', this.handleKeyUp);\n this.host.removeEventListener('keydown', this.handleKeyDown);\n }\n\n private handleFocus = (): void => {\n if (!this.clicking && this.hoverPaneState === 'hidden') {\n this.showHoverPane({\n anchor: 'host',\n });\n }\n this.clicking = false;\n };\n\n private handleBlur = (): void => {\n if (this.hoverPaneState !== 'hidden') {\n this.fadeOutHoverPane();\n }\n };\n\n private handlePointerDown = (): void => {\n this.clicking = true;\n };\n\n private handleKeyDown = (e: KeyboardEvent): void => {\n if (\n (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&\n this.hoverPaneState !== 'hidden'\n ) {\n e.preventDefault();\n }\n };\n\n private handleKeyUp = (e: KeyboardEvent): void => {\n if (this.hoverPaneState === 'hidden' || !this.hoverPane) return;\n if (e.key === 'ArrowDown') {\n this.hoverPane.tabIndex = 1;\n this.hoverPane.focus();\n }\n\n const isArrowUp = e.key === 'ArrowUp';\n const isEscape = e.key === 'Escape' || e.key === 'Esc';\n\n if (isEscape) {\n this.fadeOutHoverPane();\n }\n if (isArrowUp || isEscape) {\n this.hoverPane.tabIndex = -1;\n this.host.acquireFocus();\n }\n };\n\n /**\n * Handler for the mouseenter event on the host element.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseEnter = (e: MouseEvent): void => {\n // Delegate to the mousemove handler, as they are currently processed identically\n this.handleMouseMove(e);\n };\n\n /**\n * Handler for the mousemove event on the host element.\n * Aborts any pending hide/fade-out for the hover pane, and restarts the\n * timer to show it.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseMove = (e: MouseEvent): void => {\n // The mouse is within the tile, so abort any pending removal of the hover pane\n clearTimeout(this.hideTimer);\n\n // If the hover pane is currently fading out, just make it fade back in where it is\n if (this.hoverPaneState === 'fading-out') {\n this.hoverPaneState = 'shown';\n this.hoverPane?.classList.add('fade-in');\n }\n\n // Restart the timer to show the hover pane anytime the mouse moves within the tile\n if (this.hoverPaneState === 'hidden') {\n this.restartShowHoverPaneTimer();\n this.lastPointerClientPos = { x: e.clientX, y: e.clientY };\n }\n };\n\n /**\n * Handler for the mouseleave event on the host element.\n * Hides the hover pane if present, and aborts the timer for showing it.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseLeave = (): void => {\n this.host.releaseFocus();\n\n // Abort any timer to show the hover pane, as the mouse has left the tile\n clearTimeout(this.showTimer);\n\n // Hide the hover pane if it's already been shown\n if (this.hoverPaneState !== 'hidden') {\n this.hideTimer = window.setTimeout(() => {\n this.fadeOutHoverPane();\n }, this.hideDelay);\n }\n };\n\n /**\n * Handler for the touchstart event on the host element.\n * Begins the timer for recognizing a long press event.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleTouchStart = (e: TouchEvent): void => {\n clearTimeout(this.longPressTimer);\n\n if (e.touches.length === 1) {\n this.longPressTimer = window.setTimeout(() => {\n if (this.hoverPaneState === 'hidden') {\n this.showHoverPane();\n }\n }, this.longPressDelay);\n\n this.lastPointerClientPos = {\n x: e.touches[0].clientX,\n y: e.touches[0].clientY,\n };\n }\n };\n\n /**\n * Handler for events that should cancel a pending long press event\n * (touchmove, touchend, touchcancel). Aborts the timer for recognizing\n * a long press.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleLongPressCancel = (): void => {\n clearTimeout(this.longPressTimer);\n };\n\n /**\n * Handler for the contextmenu event, which should be suppressed during\n * mobile long-press events on the host element.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleContextMenu = (e: Event): void => {\n e.preventDefault();\n };\n\n /**\n * Immediately causes the hover pane to begin fading out, if it is present.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleBackdropInteraction = (e: Event): void => {\n if (this.hoverPaneState !== 'hidden') {\n this.fadeOutHoverPane();\n }\n e.preventDefault();\n e.stopPropagation();\n };\n\n /**\n * Aborts and restarts the timer for showing the hover pane.\n */\n private restartShowHoverPaneTimer(): void {\n clearTimeout(this.showTimer);\n this.showTimer = window.setTimeout(() => {\n this.host.acquireFocus();\n this.showHoverPane();\n }, this.showDelay);\n }\n\n /**\n * Causes this tile's hover pane to be rendered, positioned, and made visible.\n */\n private async showHoverPane(\n options: {\n anchor: HoverPanePositionAnchor;\n } = {\n anchor: 'cursor',\n },\n ): Promise<void> {\n this.hoverPaneState = 'shown';\n this.host.requestUpdate();\n\n // Wait for the state update to render the hover pane\n await this.host.updateComplete;\n\n // Ensure the hover pane element is still in the document before showing,\n // as it might have been removed by the previous update.\n if (!this.hoverPane?.isConnected) return;\n\n this.hoverPane?.showPopover?.();\n await new Promise(resolve => {\n // Pane sizes aren't accurate until next frame\n requestAnimationFrame(resolve);\n });\n\n // Apply the correct positioning to the hover pane\n this.repositionHoverPane(options.anchor);\n\n // The hover pane is initially not visible (to avoid it shifting around\n // while being positioned). Since it now has the correct positioning, we\n // can make it visible and begin its fade-in animation.\n this.hoverPane?.classList.add('visible', 'fade-in');\n }\n\n /**\n * Causes this tile's hover pane to begin fading out and starts\n * the timer for it to be removed.\n */\n private fadeOutHoverPane(): void {\n this.hoverPaneState = 'fading-out';\n this.hoverPane?.classList.remove('fade-in');\n\n clearTimeout(this.hideTimer);\n this.hideTimer = window.setTimeout(() => {\n this.hoverPaneState = 'hidden';\n if (this.hoverPane) {\n this.hoverPane.tabIndex = -1;\n }\n this.host.requestUpdate();\n }, 100);\n }\n\n /**\n * Positions the hover pane with the correct offsets.\n */\n private repositionHoverPane(anchor: HoverPanePositionAnchor): void {\n if (!this.hoverPane) return;\n\n const { top, left } = this.makePaneDesiredOffsets(anchor);\n\n this.hoverPane.style.top = `${top}px`;\n this.hoverPane.style.left = `${left}px`;\n }\n}\n"]}
1
+ {"version":3,"file":"hover-pane-controller.js","sourceRoot":"","sources":["../../../../src/tiles/hover/hover-pane-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,EAEJ,OAAO,GAGR,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAoEpC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,EAAE,EAAE,CAC7D,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEpC,MAAM,OAAO,mBAAmB;IAsF9B;IACE,wEAAwE;IACvD,I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AAG,GAAG,GAAG,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { SortParam } from '@internetarchive/search-service';\r\nimport {\r\n html,\r\n HTMLTemplateResult,\r\n nothing,\r\n ReactiveController,\r\n ReactiveControllerHost,\r\n} from 'lit';\r\nimport type { TileModel } from '../../models';\r\nimport type { CollectionTitles } from '../../data-source/models';\r\nimport { msg } from '@lit/localize';\r\n\r\ntype HoverPaneState = 'hidden' | 'shown' | 'fading-out';\r\n\r\n// the anchor point of the hover pane\r\n// can be either the mouse cursor or near the host element\r\n// in the case of mouse navigation, we want it to follow the cursor\r\n// in the case of keyboard navigation, we want it to appear near the host element\r\ntype HoverPanePositionAnchor = 'host' | 'cursor';\r\n\r\nexport interface HoverPaneProperties {\r\n model?: TileModel;\r\n baseNavigationUrl?: string;\r\n baseImageUrl?: string;\r\n loggedIn: boolean;\r\n suppressBlurring: boolean;\r\n sortParam: SortParam | null;\r\n collectionTitles?: CollectionTitles;\r\n}\r\n\r\nexport interface HoverPaneControllerOptions {\r\n offsetX?: number;\r\n offsetY?: number;\r\n enableLongPress?: boolean;\r\n showDelay?: number;\r\n hideDelay?: number;\r\n longPressDelay?: number;\r\n mobileBreakpoint?: number;\r\n}\r\n\r\n/** A common interface for providing a hover pane element. */\r\nexport interface HoverPaneProviderInterface {\r\n /** Returns the provider's currently rendered hover pane element. */\r\n getHoverPane(): HTMLElement | undefined;\r\n /** Returns properties that should be passed to the hover pane. */\r\n getHoverPaneProps(): HoverPaneProperties;\r\n /** When user has keyboard navigated out of more info, we want the host to get focus */\r\n acquireFocus(): void;\r\n /** When user has keyboard navigated out of more info, we want the host to lose focus */\r\n releaseFocus(): void;\r\n}\r\n\r\nexport interface ToggleHoverPaneOptions {\r\n coords: { x: number; y: number };\r\n enableTouchBackdrop?: boolean;\r\n}\r\n\r\n/**\r\n * An interface for interacting with hover pane controllers (e.g.,\r\n * to retrieve their current hover pane template).\r\n */\r\nexport interface HoverPaneControllerInterface extends ReactiveController {\r\n /**\r\n * Returns the hover pane template to render based on this controller's\r\n * current state. The returned template may be `nothing` if the hover\r\n * pane should not currently be rendered.\r\n */\r\n getTemplate(): HTMLTemplateResult | typeof nothing;\r\n\r\n /**\r\n * Requests to manually toggle the state of the hover pane.\r\n * If the hover pane is already shown, it will begin fading out and then\r\n * subsequently be hidden and removed. If the hover pane is already fading\r\n * out or hidden, it will fade back in and be shown.\r\n */\r\n toggleHoverPane(options: ToggleHoverPaneOptions): void;\r\n}\r\n\r\nconst clamp = (val: number, min = -Infinity, max = Infinity) =>\r\n Math.max(min, Math.min(val, max));\r\n\r\nexport class HoverPaneController implements HoverPaneControllerInterface {\r\n /**\r\n * The hover pane element attached to this controller's host.\r\n */\r\n private hoverPane?: HTMLElement;\r\n\r\n /**\r\n * The properties to be passed to the hover pane element\r\n */\r\n private hoverPaneProps?: HoverPaneProperties;\r\n\r\n /**\r\n * The breakpoint (in pixels) below which the mobile interface should be used.\r\n */\r\n private mobileBreakpoint?: number = 600;\r\n\r\n /**\r\n * The number of horizontal pixels the hover pane should be offset from the\r\n * pointer position.\r\n */\r\n private offsetX: number = -10;\r\n\r\n /**\r\n * The number of vertical pixels the hover pane should be offset from the\r\n * pointer position.\r\n */\r\n private offsetY: number = 15;\r\n\r\n /**\r\n * The delay between the mouse idling within the host element and when the hover\r\n * pane should begin fading in (in milliseconds).\r\n */\r\n private showDelay: number = 300;\r\n\r\n /**\r\n * The delay between when the mouse leaves the host element and when the hover\r\n * pane should begin fading out (in milliseconds).\r\n */\r\n private hideDelay: number = 100;\r\n\r\n /**\r\n * The delay between when a touch event begins on the host element and when the\r\n * hover pane should begin fading in (in milliseconds).\r\n */\r\n private longPressDelay: number = 600;\r\n\r\n /**\r\n * Whether long press interactions should cause the hover pane to appear (when\r\n * below the mobile breakpoint).\r\n */\r\n private enableLongPress: boolean = false;\r\n\r\n /**\r\n * Used to control the current state of this provider's hover pane.\r\n * - `'hidden'` => The hover pane is not present at all.\r\n * - `'shown'` => The hover pane is either fading in or fully visible.\r\n * - `'fading-out'` => The hover pane is fading out and about to be removed.\r\n */\r\n private hoverPaneState: HoverPaneState = 'hidden';\r\n\r\n /** The timer ID for showing the hover pane */\r\n private showTimer?: number;\r\n\r\n /** The timer ID for hiding the hover pane */\r\n private hideTimer?: number;\r\n\r\n /** The timer ID for recognizing a long press event */\r\n private longPressTimer?: number;\r\n\r\n /**\r\n * Whether the touch backdrop should currently be rendered irrespective of other touch\r\n * interactions being enabled.\r\n */\r\n private forceTouchBackdrop: boolean = false;\r\n\r\n /** A record of the last mouse position on the host element, for positioning the hover pane */\r\n private lastPointerClientPos = { x: 0, y: 0 };\r\n\r\n /**\r\n * A flag to track whether the host element is being clicked by a pointer device, so that we\r\n * don't trigger unnecessary keyboard focus behaviors on click. This is needed, e.g., to prevent\r\n * the hover pane from appearing immediately at its `host` positioning on click, which can\r\n * obstruct the host element itself (due to the ordering of events fired).\r\n */\r\n private clicking = false;\r\n\r\n constructor(\r\n /** The host element to which this controller should attach listeners */\r\n private readonly host: ReactiveControllerHost &\r\n HoverPaneProviderInterface &\r\n HTMLElement,\r\n /** Options for adjusting the hover pane behavior (offsets, delays, etc.) */\r\n options: HoverPaneControllerOptions = {},\r\n ) {\r\n this.mobileBreakpoint = options.mobileBreakpoint ?? this.mobileBreakpoint;\r\n this.offsetX = options.offsetX ?? this.offsetX;\r\n this.offsetY = options.offsetY ?? this.offsetY;\r\n this.showDelay = options.showDelay ?? this.showDelay;\r\n this.hideDelay = options.hideDelay ?? this.hideDelay;\r\n this.longPressDelay = options.longPressDelay ?? this.longPressDelay;\r\n this.enableLongPress = options.enableLongPress ?? this.enableLongPress;\r\n\r\n this.host.addController(this);\r\n }\r\n\r\n hostConnected(): void {\r\n this.attachListeners();\r\n }\r\n\r\n hostDisconnected(): void {\r\n this.detachListeners();\r\n }\r\n\r\n hostUpdated(): void {\r\n this.hoverPane = this.host.getHoverPane();\r\n this.hoverPaneProps = this.host.getHoverPaneProps();\r\n }\r\n\r\n /** @inheritdoc */\r\n getTemplate(): HTMLTemplateResult | typeof nothing {\r\n this.hoverPaneProps = this.host.getHoverPaneProps();\r\n\r\n return this.shouldRenderHoverPane\r\n ? html`\r\n ${this.touchBackdropTemplate}\r\n <tile-hover-pane\r\n popover\r\n tabindex=\"-1\"\r\n aria-describedby=\"tile-hover-pane-aria-description\"\r\n .model=${this.hoverPaneProps?.model}\r\n .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}\r\n .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}\r\n .loggedIn=${this.hoverPaneProps?.loggedIn}\r\n .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}\r\n .sortParam=${this.hoverPaneProps?.sortParam}\r\n .collectionTitles=${this.hoverPaneProps?.collectionTitles}\r\n .mobileBreakpoint=${this.mobileBreakpoint}\r\n .currentWidth=${window.innerWidth}\r\n ></tile-hover-pane>\r\n <div id=\"tile-hover-pane-aria-description\" class=\"sr-only\">\r\n ${msg('Press Up Arrow to exit item detail preview')}\r\n </div>\r\n `\r\n : nothing;\r\n }\r\n\r\n /** @inheritdoc */\r\n toggleHoverPane(options: ToggleHoverPaneOptions): void {\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.fadeOutHoverPane();\r\n this.forceTouchBackdrop = false;\r\n } else {\r\n this.lastPointerClientPos = options.coords;\r\n this.forceTouchBackdrop = options.enableTouchBackdrop ?? false;\r\n this.showHoverPane();\r\n }\r\n }\r\n\r\n /**\r\n * Produces a template for the invisible touch capture backdrop that\r\n * is used to cancel the hover pane on touch devices. We want any\r\n * touch interaction on the backdrop to remove the hover pane, and\r\n * we don't want to bubble up mouse events that would otherwise\r\n * affect the state of the hover pane (e.g., fading it back in).\r\n */\r\n private get touchBackdropTemplate(): HTMLTemplateResult | typeof nothing {\r\n return this.showTouchBackdrop\r\n ? html`<div\r\n id=\"touch-backdrop\"\r\n @touchstart=${this.handleBackdropInteraction}\r\n @touchmove=${this.handleBackdropInteraction}\r\n @touchend=${this.handleBackdropInteraction}\r\n @touchcancel=${this.handleBackdropInteraction}\r\n @mouseenter=${(e: MouseEvent) => e.stopPropagation()}\r\n @mousemove=${(e: MouseEvent) => e.stopPropagation()}\r\n @mouseleave=${(e: MouseEvent) => e.stopPropagation()}\r\n ></div>`\r\n : nothing;\r\n }\r\n\r\n private get showTouchBackdrop(): boolean {\r\n return (\r\n (this.isTouchEnabled && this.enableLongPress) || this.forceTouchBackdrop\r\n );\r\n }\r\n\r\n /** Whether to use the mobile layout */\r\n private get isMobileView(): boolean {\r\n return !!this.mobileBreakpoint && window.innerWidth < this.mobileBreakpoint;\r\n }\r\n\r\n private get isHoverEnabled(): boolean {\r\n return window.matchMedia('(hover: hover)').matches;\r\n }\r\n\r\n private get isTouchEnabled(): boolean {\r\n return (\r\n 'ontouchstart' in window &&\r\n window.matchMedia('(any-pointer: coarse)').matches\r\n );\r\n }\r\n\r\n /** Whether this controller should currently render its hover pane. */\r\n private get shouldRenderHoverPane(): boolean {\r\n return this.hoverPaneState !== 'hidden';\r\n }\r\n\r\n /**\r\n * Returns the desired top/left offsets (in pixels) for this tile's hover pane.\r\n * The desired offsets balance positioning the hover pane under the primary pointer\r\n * while preventing it from flowing outside the viewport. The returned offsets are\r\n * relative to the viewport, intended to position the pane as a popover element.\r\n *\r\n * These offsets are only valid if the hover pane is already rendered with its\r\n * correct width and height. If the hover pane is not present, the returned offsets\r\n * will simply represent the current pointer position.\r\n */\r\n private makePaneDesiredOffsets(anchor: HoverPanePositionAnchor): {\r\n top: number;\r\n left: number;\r\n } {\r\n // Try to find offsets for the hover pane that:\r\n // (a) cause it to lie entirely within the viewport, and\r\n // (b) to the extent possible, minimize the distance between the\r\n // nearest corner of the hover pane and the mouse/host element position\r\n // (with some additional offsets applied after the fact).\r\n\r\n let [left, top] = [0, 0];\r\n switch (anchor) {\r\n case 'host':\r\n const hostRect = this.host.getBoundingClientRect();\r\n // slight inset from host top left corner\r\n left = hostRect.left + 20;\r\n top = hostRect.top + 30;\r\n break;\r\n case 'cursor':\r\n left = this.lastPointerClientPos.x;\r\n top = this.lastPointerClientPos.y;\r\n break;\r\n }\r\n\r\n // Flip the hover pane according to which quadrant of the viewport the coordinates are in.\r\n // (Similar to how Wikipedia's link hover panes work)\r\n const flipHorizontal = left > window.innerWidth / 2;\r\n const flipVertical = top > window.innerHeight / 2;\r\n\r\n const hoverPaneRect = this.hoverPane?.getBoundingClientRect();\r\n if (hoverPaneRect) {\r\n // If we need to flip the hover pane, do so by subtracting its width/height from left/top\r\n if (flipHorizontal) {\r\n left -= hoverPaneRect.width;\r\n }\r\n if (flipVertical) {\r\n top -= hoverPaneRect.height;\r\n }\r\n\r\n // Apply desired offsets from the target position\r\n left += (flipHorizontal ? -1 : 1) * this.offsetX;\r\n top += (flipVertical ? -1 : 1) * this.offsetY;\r\n\r\n // On mobile view, shunt the hover pane to avoid overflowing the viewport\r\n if (this.isMobileView) {\r\n left = clamp(left, 20, window.innerWidth - hoverPaneRect.width - 20);\r\n top = clamp(top, 20, window.innerHeight - hoverPaneRect.height - 20);\r\n }\r\n }\r\n\r\n left += window.scrollX;\r\n top += window.scrollY;\r\n\r\n return { left, top };\r\n }\r\n\r\n /**\r\n * Adds to the host element all the listeners necessary to make the\r\n * hover pane functional.\r\n */\r\n private attachListeners(): void {\r\n // keyboard navigation listeners\r\n this.host.addEventListener('focus', this.handleFocus);\r\n this.host.addEventListener('blur', this.handleBlur);\r\n this.host.addEventListener('pointerdown', this.handlePointerDown);\r\n this.host.addEventListener('keyup', this.handleKeyUp);\r\n this.host.addEventListener('keydown', this.handleKeyDown);\r\n\r\n if (this.isHoverEnabled) {\r\n this.host.addEventListener('mouseenter', this.handleMouseEnter);\r\n this.host.addEventListener('mousemove', this.handleMouseMove);\r\n this.host.addEventListener('mouseleave', this.handleMouseLeave);\r\n }\r\n\r\n if (this.isTouchEnabled && this.enableLongPress) {\r\n this.host.addEventListener('touchstart', this.handleTouchStart);\r\n this.host.addEventListener('touchmove', this.handleLongPressCancel);\r\n this.host.addEventListener('touchend', this.handleLongPressCancel);\r\n this.host.addEventListener('touchcancel', this.handleLongPressCancel);\r\n this.host.addEventListener('contextmenu', this.handleContextMenu);\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the hover pane listeners from the host element.\r\n */\r\n private detachListeners(): void {\r\n this.host.removeEventListener('mouseenter', this.handleMouseEnter);\r\n this.host.removeEventListener('mousemove', this.handleMouseMove);\r\n this.host.removeEventListener('mouseleave', this.handleMouseLeave);\r\n this.host.removeEventListener('touchstart', this.handleTouchStart);\r\n this.host.removeEventListener('touchmove', this.handleLongPressCancel);\r\n this.host.removeEventListener('touchend', this.handleLongPressCancel);\r\n this.host.removeEventListener('touchcancel', this.handleLongPressCancel);\r\n this.host.removeEventListener('contextmenu', this.handleContextMenu);\r\n\r\n // keyboard navigation listeners\r\n this.host.removeEventListener('focus', this.handleFocus);\r\n this.host.removeEventListener('blur', this.handleBlur);\r\n this.host.removeEventListener('keyup', this.handleKeyUp);\r\n this.host.removeEventListener('keydown', this.handleKeyDown);\r\n }\r\n\r\n private handleFocus = (): void => {\r\n if (!this.clicking && this.hoverPaneState === 'hidden') {\r\n this.showHoverPane({\r\n anchor: 'host',\r\n });\r\n }\r\n this.clicking = false;\r\n };\r\n\r\n private handleBlur = (): void => {\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.fadeOutHoverPane();\r\n }\r\n };\r\n\r\n private handlePointerDown = (): void => {\r\n this.clicking = true;\r\n };\r\n\r\n private handleKeyDown = (e: KeyboardEvent): void => {\r\n if (\r\n (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&\r\n this.hoverPaneState !== 'hidden'\r\n ) {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n private handleKeyUp = (e: KeyboardEvent): void => {\r\n if (this.hoverPaneState === 'hidden' || !this.hoverPane) return;\r\n if (e.key === 'ArrowDown') {\r\n this.hoverPane.tabIndex = 1;\r\n this.hoverPane.focus();\r\n }\r\n\r\n const isArrowUp = e.key === 'ArrowUp';\r\n const isEscape = e.key === 'Escape' || e.key === 'Esc';\r\n\r\n if (isEscape) {\r\n this.fadeOutHoverPane();\r\n }\r\n if (isArrowUp || isEscape) {\r\n this.hoverPane.tabIndex = -1;\r\n this.host.acquireFocus();\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the mouseenter event on the host element.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseEnter = (e: MouseEvent): void => {\r\n // Delegate to the mousemove handler, as they are currently processed identically\r\n this.handleMouseMove(e);\r\n };\r\n\r\n /**\r\n * Handler for the mousemove event on the host element.\r\n * Aborts any pending hide/fade-out for the hover pane, and restarts the\r\n * timer to show it.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseMove = (e: MouseEvent): void => {\r\n // The mouse is within the tile, so abort any pending removal of the hover pane\r\n clearTimeout(this.hideTimer);\r\n\r\n // If the hover pane is currently fading out, just make it fade back in where it is\r\n if (this.hoverPaneState === 'fading-out') {\r\n this.hoverPaneState = 'shown';\r\n this.hoverPane?.classList.add('fade-in');\r\n }\r\n\r\n // Restart the timer to show the hover pane anytime the mouse moves within the tile\r\n if (this.hoverPaneState === 'hidden') {\r\n this.restartShowHoverPaneTimer();\r\n this.lastPointerClientPos = { x: e.clientX, y: e.clientY };\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the mouseleave event on the host element.\r\n * Hides the hover pane if present, and aborts the timer for showing it.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseLeave = (): void => {\r\n this.host.releaseFocus();\r\n\r\n // Abort any timer to show the hover pane, as the mouse has left the tile\r\n clearTimeout(this.showTimer);\r\n\r\n // Hide the hover pane if it's already been shown\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.hideTimer = window.setTimeout(() => {\r\n this.fadeOutHoverPane();\r\n }, this.hideDelay);\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the touchstart event on the host element.\r\n * Begins the timer for recognizing a long press event.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleTouchStart = (e: TouchEvent): void => {\r\n clearTimeout(this.longPressTimer);\r\n\r\n if (e.touches.length === 1) {\r\n this.longPressTimer = window.setTimeout(() => {\r\n if (this.hoverPaneState === 'hidden') {\r\n this.showHoverPane();\r\n }\r\n }, this.longPressDelay);\r\n\r\n this.lastPointerClientPos = {\r\n x: e.touches[0].clientX,\r\n y: e.touches[0].clientY,\r\n };\r\n }\r\n };\r\n\r\n /**\r\n * Handler for events that should cancel a pending long press event\r\n * (touchmove, touchend, touchcancel). Aborts the timer for recognizing\r\n * a long press.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleLongPressCancel = (): void => {\r\n clearTimeout(this.longPressTimer);\r\n };\r\n\r\n /**\r\n * Handler for the contextmenu event, which should be suppressed during\r\n * mobile long-press events on the host element.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleContextMenu = (e: Event): void => {\r\n e.preventDefault();\r\n };\r\n\r\n /**\r\n * Immediately causes the hover pane to begin fading out, if it is present.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleBackdropInteraction = (e: Event): void => {\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.fadeOutHoverPane();\r\n }\r\n e.preventDefault();\r\n e.stopPropagation();\r\n };\r\n\r\n /**\r\n * Aborts and restarts the timer for showing the hover pane.\r\n */\r\n private restartShowHoverPaneTimer(): void {\r\n clearTimeout(this.showTimer);\r\n this.showTimer = window.setTimeout(() => {\r\n this.host.acquireFocus();\r\n this.showHoverPane();\r\n }, this.showDelay);\r\n }\r\n\r\n /**\r\n * Causes this tile's hover pane to be rendered, positioned, and made visible.\r\n */\r\n private async showHoverPane(\r\n options: {\r\n anchor: HoverPanePositionAnchor;\r\n } = {\r\n anchor: 'cursor',\r\n },\r\n ): Promise<void> {\r\n this.hoverPaneState = 'shown';\r\n this.host.requestUpdate();\r\n\r\n // Wait for the state update to render the hover pane\r\n await this.host.updateComplete;\r\n\r\n // Ensure the hover pane element is still in the document before showing,\r\n // as it might have been removed by the previous update.\r\n if (!this.hoverPane?.isConnected) return;\r\n\r\n if (this.hoverPane && !this.hoverPane.matches(':popover-open')) {\r\n this.hoverPane.showPopover?.();\r\n }\r\n await new Promise(resolve => {\r\n // Pane sizes aren't accurate until next frame\r\n requestAnimationFrame(resolve);\r\n });\r\n\r\n // Apply the correct positioning to the hover pane\r\n this.repositionHoverPane(options.anchor);\r\n\r\n // The hover pane is initially not visible (to avoid it shifting around\r\n // while being positioned). Since it now has the correct positioning, we\r\n // can make it visible and begin its fade-in animation.\r\n this.hoverPane?.classList.add('visible', 'fade-in');\r\n }\r\n\r\n /**\r\n * Causes this tile's hover pane to begin fading out and starts\r\n * the timer for it to be removed.\r\n */\r\n private fadeOutHoverPane(): void {\r\n this.hoverPaneState = 'fading-out';\r\n this.hoverPane?.classList.remove('fade-in');\r\n\r\n clearTimeout(this.hideTimer);\r\n this.hideTimer = window.setTimeout(() => {\r\n this.hoverPaneState = 'hidden';\r\n if (this.hoverPane) {\r\n this.hoverPane.tabIndex = -1;\r\n }\r\n this.host.requestUpdate();\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Positions the hover pane with the correct offsets.\r\n */\r\n private repositionHoverPane(anchor: HoverPanePositionAnchor): void {\r\n if (!this.hoverPane) return;\r\n\r\n const { top, left } = this.makePaneDesiredOffsets(anchor);\r\n\r\n this.hoverPane.style.top = `${top}px`;\r\n this.hoverPane.style.left = `${left}px`;\r\n }\r\n}\r\n"]}
@@ -76,8 +76,8 @@ describe('Hover Pane Controller', () => {
76
76
  expect(host.controller?.getTemplate()).to.equal(nothing);
77
77
  });
78
78
  it('should produce a hover pane template after mousemove, and hide it after mouseleave', async () => {
79
- const host = await fixture(html `<host-element
80
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
79
+ const host = await fixture(html `<host-element
80
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
81
81
  ></host-element>`);
82
82
  host.dispatchEvent(new MouseEvent('mousemove'));
83
83
  // Need to wait a tick for the event handlers to run
@@ -93,8 +93,8 @@ describe('Hover Pane Controller', () => {
93
93
  expect(host.controller?.getTemplate()).to.equal(nothing);
94
94
  });
95
95
  it('should produce a hover pane template after mouseenter, even without mousemove', async () => {
96
- const host = await fixture(html `<host-element
97
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
96
+ const host = await fixture(html `<host-element
97
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
98
98
  ></host-element>`);
99
99
  host.dispatchEvent(new MouseEvent('mouseenter'));
100
100
  // Need to wait a tick for the event handlers to run
@@ -104,8 +104,8 @@ describe('Hover Pane Controller', () => {
104
104
  expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult
105
105
  });
106
106
  it('should immediately fade back in if mouse enters while fading out', async () => {
107
- const host = await fixture(html `<host-element
108
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
107
+ const host = await fixture(html `<host-element
108
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
109
109
  ></host-element>`);
110
110
  // Enter the host element and wait for the show handlers to run
111
111
  host.dispatchEvent(new MouseEvent('mousemove'));
@@ -126,8 +126,8 @@ describe('Hover Pane Controller', () => {
126
126
  expect(host.controller?.getTemplate()).not.to.equal(nothing);
127
127
  });
128
128
  it('should flip hover pane if it would overflow the viewport', async () => {
129
- const host = await fixture(html `<host-element
130
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
129
+ const host = await fixture(html `<host-element
130
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
131
131
  ></host-element>`);
132
132
  host.dispatchEvent(new MouseEvent('mousemove', { clientX: 800, clientY: 600 }));
133
133
  // Need to wait a tick for the event handlers to run
@@ -139,10 +139,37 @@ describe('Hover Pane Controller', () => {
139
139
  expect(host.getHoverPane()?.getBoundingClientRect()?.right).to.be.lessThan(window.innerWidth);
140
140
  expect(host.getHoverPane()?.getBoundingClientRect()?.bottom).to.be.lessThan(window.innerHeight);
141
141
  });
142
+ it('should not call showPopover when the hover pane is already open', async () => {
143
+ const host = await fixture(html `<host-element
144
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
145
+ ></host-element>`);
146
+ // Show the pane and confirm the :popover-open state
147
+ host.dispatchEvent(new MouseEvent('mousemove'));
148
+ await new Promise(resolve => {
149
+ setTimeout(resolve, 0);
150
+ });
151
+ await host.updateComplete;
152
+ const pane = host.getHoverPane();
153
+ expect(pane?.matches(':popover-open')).to.be.true;
154
+ const showPopoverSpy = sinon.spy(pane, 'showPopover');
155
+ // Simulate the condition where the hover pane has finished its fade out
156
+ // but its popover has not yet been hidden.
157
+ host.controller.hoverPaneState =
158
+ 'hidden';
159
+ // Subsequent mousemove tries to re-show the hover pane...
160
+ host.dispatchEvent(new MouseEvent('mousemove'));
161
+ await new Promise(resolve => {
162
+ setTimeout(resolve, 10);
163
+ });
164
+ await host.updateComplete;
165
+ // ...but should NOT call showPopover() again
166
+ expect(showPopoverSpy.called).to.be.false;
167
+ expect(host.getHoverPane()?.matches(':popover-open')).to.be.true;
168
+ });
142
169
  it('should gracefully handle undefined hover pane from host element', async () => {
143
- const host = await fixture(html `<host-element
144
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
145
- ?suppressHoverPane=${true}
170
+ const host = await fixture(html `<host-element
171
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
172
+ ?suppressHoverPane=${true}
146
173
  ></host-element>`);
147
174
  host.dispatchEvent(new MouseEvent('mousemove'));
148
175
  // Need to wait a tick for the event handlers to run
@@ -170,12 +197,12 @@ describe('Hover Pane Controller', () => {
170
197
  touches: [new Touch({ identifier: 0, target: host })],
171
198
  });
172
199
  it('should produce a hover pane after long press', async () => {
173
- const host = await fixture(html `<host-element
200
+ const host = await fixture(html `<host-element
174
201
  .controllerOptions=${{
175
202
  showDelay: 0,
176
203
  longPressDelay: 0,
177
204
  enableLongPress: true,
178
- }}
205
+ }}
179
206
  ></host-element>`);
180
207
  // Touch the host element and wait for the long press handlers to run
181
208
  host.dispatchEvent(getTouchStartEvent(host));
@@ -185,12 +212,12 @@ describe('Hover Pane Controller', () => {
185
212
  expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult
186
213
  });
187
214
  it('should cancel a long press by moving', async () => {
188
- const host = await fixture(html `<host-element
215
+ const host = await fixture(html `<host-element
189
216
  .controllerOptions=${{
190
217
  showDelay: 0,
191
218
  longPressDelay: 100,
192
219
  enableLongPress: true,
193
- }}
220
+ }}
194
221
  ></host-element>`);
195
222
  // Touch the host element
196
223
  host.dispatchEvent(getTouchStartEvent(host));
@@ -205,12 +232,12 @@ describe('Hover Pane Controller', () => {
205
232
  expect(host.controller?.getTemplate()).to.equal(nothing);
206
233
  });
207
234
  it('should cancel a long press by ending touch', async () => {
208
- const host = await fixture(html `<host-element
235
+ const host = await fixture(html `<host-element
209
236
  .controllerOptions=${{
210
237
  showDelay: 0,
211
238
  longPressDelay: 100,
212
239
  enableLongPress: true,
213
- }}
240
+ }}
214
241
  ></host-element>`);
215
242
  // Touch the host element
216
243
  host.dispatchEvent(getTouchStartEvent(host));
@@ -225,12 +252,12 @@ describe('Hover Pane Controller', () => {
225
252
  expect(host.controller?.getTemplate()).to.equal(nothing);
226
253
  });
227
254
  it('should cancel a long press by cancelling touch (e.g., too many touch points)', async () => {
228
- const host = await fixture(html `<host-element
255
+ const host = await fixture(html `<host-element
229
256
  .controllerOptions=${{
230
257
  showDelay: 0,
231
258
  longPressDelay: 100,
232
259
  enableLongPress: true,
233
- }}
260
+ }}
234
261
  ></host-element>`);
235
262
  // Touch the host element
236
263
  host.dispatchEvent(getTouchStartEvent(host));
@@ -245,14 +272,14 @@ describe('Hover Pane Controller', () => {
245
272
  expect(host.controller?.getTemplate()).to.equal(nothing);
246
273
  });
247
274
  it('should close the hover pane on mobile when touching the backdrop', async () => {
248
- const host = await fixture(html `<host-element
275
+ const host = await fixture(html `<host-element
249
276
  .controllerOptions=${{
250
277
  showDelay: 0,
251
278
  hideDelay: 0,
252
279
  longPressDelay: 0,
253
280
  enableLongPress: true,
254
281
  mobileBreakpoint: 9999, // Ensure we get the mobile view
255
- }}
282
+ }}
256
283
  ></host-element>`);
257
284
  // Touch the host element
258
285
  host.dispatchEvent(getTouchStartEvent(host));
@@ -273,8 +300,8 @@ describe('Hover Pane Controller', () => {
273
300
  });
274
301
  describe('keyboard accessibility', () => {
275
302
  it('should call host getBoundingClientRect if anchor is host', async () => {
276
- const host = await fixture(html `<host-element
277
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
303
+ const host = await fixture(html `<host-element
304
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
278
305
  ></host-element>`);
279
306
  const getBoundingClientRectSpy = sinon.spy(host, 'getBoundingClientRect');
280
307
  host.dispatchEvent(new FocusEvent('focus'));
@@ -285,8 +312,8 @@ describe('Hover Pane Controller', () => {
285
312
  expect(getBoundingClientRectSpy.called).to.be.true;
286
313
  });
287
314
  it('should show hover pane on focus', async () => {
288
- const host = await fixture(html `<host-element
289
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
315
+ const host = await fixture(html `<host-element
316
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
290
317
  ></host-element>`);
291
318
  host.dispatchEvent(new FocusEvent('focus'));
292
319
  // Need to wait a tick for the event handlers to run
@@ -296,8 +323,8 @@ describe('Hover Pane Controller', () => {
296
323
  expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult
297
324
  });
298
325
  it('should hide hover pane on blur', async () => {
299
- const host = await fixture(html `<host-element
300
- .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
326
+ const host = await fixture(html `<host-element
327
+ .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}
301
328
  ></host-element>`);
302
329
  host.dispatchEvent(new FocusEvent('focus'));
303
330
  // Need to wait a tick for the event handlers to run
@@ -1 +1 @@
1
- {"version":3,"file":"hover-pane-controller.test.js","sourceRoot":"","sources":["../../../../test/tiles/hover/hover-pane-controller.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,mBAAmB,GAKpB,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAG+B,sBAAiB,GAAY,KAAK,CAAC;IA+ClE,CAAC;IAzCC,MAAM;QACJ,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC;IACnD,CAAC;IAES,YAAY;QACpB,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY,KAAU,CAAC;IAEvB,YAAY,KAAU,CAAC;IAEvB,YAAY;QACV,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC7D,CAAC;IAED,iBAAiB;QACf,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC;QACpC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,SAAS,CAAC,oBAAoB,GAAG,CAAC,CAAC;QACnC,SAAS,CAAC,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACvC,SAAS,CAAC,cAAc,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AAC,CAAC;YAC3C,2CAA2C;YAC3C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html, LitElement, nothing, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport {\n HoverPaneController,\n HoverPaneControllerInterface,\n HoverPaneControllerOptions,\n HoverPaneProperties,\n HoverPaneProviderInterface,\n} from '../../../src/tiles/hover/hover-pane-controller';\nimport type { TileHoverPane } from '../../../src/tiles/hover/tile-hover-pane';\nimport { TileModel } from '../../../src/models';\nimport sinon from 'sinon';\n\n@customElement('host-element')\nclass HostElement extends LitElement implements HoverPaneProviderInterface {\n @property({ type: Object }) controllerOptions?: HoverPaneControllerOptions;\n\n @property({ type: Boolean }) suppressHoverPane: boolean = false;\n\n @query('tile-hover-pane') hoverPane?: TileHoverPane;\n\n controller?: HoverPaneControllerInterface;\n\n render(): TemplateResult {\n return html` ${this.controller?.getTemplate()} `;\n }\n\n protected firstUpdated(): void {\n this.controller = new HoverPaneController(this, this.controllerOptions);\n }\n\n acquireFocus(): void {}\n\n releaseFocus(): void {}\n\n getHoverPane(): HTMLElement | undefined {\n return this.suppressHoverPane ? undefined : this.hoverPane;\n }\n\n getHoverPaneProps(): HoverPaneProperties {\n const tileModel = new TileModel({});\n tileModel.checked = false;\n tileModel.collectionFilesCount = 1;\n tileModel.collections = ['foo', 'bar'];\n tileModel.collectionSize = 1;\n tileModel.commentCount = 1;\n tileModel.contentWarning = false;\n tileModel.creators = ['foo', 'bar'];\n tileModel.favCount = 1;\n tileModel.identifier = 'foo';\n tileModel.itemCount = 1;\n tileModel.loginRequired = false;\n tileModel.mediatype = 'data';\n tileModel.subjects = ['foo', 'bar'];\n tileModel.title = 'foo';\n tileModel.viewCount = 1;\n\n return {\n model: tileModel,\n loggedIn: false,\n suppressBlurring: false,\n sortParam: null,\n };\n }\n}\n\ndescribe('Hover Pane Controller', () => {\n let oldMatchMedia: typeof window.matchMedia;\n let oldOnTouchStart: typeof window.ontouchstart;\n\n before(() => {\n oldMatchMedia = window.matchMedia;\n oldOnTouchStart = window.ontouchstart;\n window.matchMedia = () => ({ matches: true }) as MediaQueryList;\n window.ontouchstart = () => {};\n });\n\n after(() => {\n window.matchMedia = oldMatchMedia;\n window.ontouchstart = oldOnTouchStart;\n });\n\n it('should initially provide empty template', async () => {\n const host = await fixture<HostElement>(\n html`<host-element></host-element>`,\n );\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n it('should produce a hover pane template after mousemove, and hide it after mouseleave', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n host.dispatchEvent(new MouseEvent('mousemove'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\n\n host.dispatchEvent(new MouseEvent('mouseleave'));\n // Need to wait for the fade out transition\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n it('should produce a hover pane template after mouseenter, even without mousemove', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n host.dispatchEvent(new MouseEvent('mouseenter'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\n });\n\n it('should immediately fade back in if mouse enters while fading out', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n // Enter the host element and wait for the show handlers to run\n host.dispatchEvent(new MouseEvent('mousemove'));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n // Leave the host element so it begins fading out, but not all the way\n host.dispatchEvent(new MouseEvent('mouseleave'));\n await new Promise(resolve => {\n setTimeout(resolve, 20);\n });\n\n // Re-enter the host element and wait long enough that it would disappear\n // if the hide were not cancelled\n host.dispatchEvent(new MouseEvent('mousemove'));\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\n });\n\n it('should flip hover pane if it would overflow the viewport', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n host.dispatchEvent(\n new MouseEvent('mousemove', { clientX: 800, clientY: 600 }),\n );\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n await host.updateComplete;\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\n expect(host.getHoverPane()?.getBoundingClientRect()?.right).to.be.lessThan(\n window.innerWidth,\n );\n expect(host.getHoverPane()?.getBoundingClientRect()?.bottom).to.be.lessThan(\n window.innerHeight,\n );\n });\n\n it('should gracefully handle undefined hover pane from host element', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ?suppressHoverPane=${true}\n ></host-element>`,\n );\n\n host.dispatchEvent(new MouseEvent('mousemove'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\n\n host.dispatchEvent(new MouseEvent('mouseleave'));\n await new Promise(resolve => {\n setTimeout(resolve, 20);\n });\n\n host.dispatchEvent(new MouseEvent('mousemove'));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n host.dispatchEvent(new MouseEvent('mouseleave'));\n // Need to wait for the fade out transition\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n describe('Touch & long-press', () => {\n const getTouchStartEvent = (host: EventTarget) =>\n new TouchEvent('touchstart', {\n touches: [new Touch({ identifier: 0, target: host })],\n });\n\n it('should produce a hover pane after long press', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{\n showDelay: 0,\n longPressDelay: 0,\n enableLongPress: true,\n }}\n ></host-element>`,\n );\n\n // Touch the host element and wait for the long press handlers to run\n host.dispatchEvent(getTouchStartEvent(host));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\n });\n\n it('should cancel a long press by moving', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{\n showDelay: 0,\n longPressDelay: 100,\n enableLongPress: true,\n }}\n ></host-element>`,\n );\n\n // Touch the host element\n host.dispatchEvent(getTouchStartEvent(host));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n // Move the touch point, cancelling the long press\n host.dispatchEvent(new TouchEvent('touchmove'));\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n it('should cancel a long press by ending touch', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{\n showDelay: 0,\n longPressDelay: 100,\n enableLongPress: true,\n }}\n ></host-element>`,\n );\n\n // Touch the host element\n host.dispatchEvent(getTouchStartEvent(host));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n // Lift the touch point, cancelling the long press\n host.dispatchEvent(new TouchEvent('touchend'));\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n it('should cancel a long press by cancelling touch (e.g., too many touch points)', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{\n showDelay: 0,\n longPressDelay: 100,\n enableLongPress: true,\n }}\n ></host-element>`,\n );\n\n // Touch the host element\n host.dispatchEvent(getTouchStartEvent(host));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n // Cancel the touch point, also cancelling the long press\n host.dispatchEvent(new TouchEvent('touchcancel'));\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n\n it('should close the hover pane on mobile when touching the backdrop', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{\n showDelay: 0,\n hideDelay: 0,\n longPressDelay: 0,\n enableLongPress: true,\n mobileBreakpoint: 9999, // Ensure we get the mobile view\n }}\n ></host-element>`,\n );\n\n // Touch the host element\n host.dispatchEvent(getTouchStartEvent(host));\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\n\n await host.updateComplete;\n\n // Touch the backdrop\n host.shadowRoot\n ?.querySelector('#touch-backdrop')\n ?.dispatchEvent(new TouchEvent('touchstart'));\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n });\n\n describe('keyboard accessibility', () => {\n it('should call host getBoundingClientRect if anchor is host', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n const getBoundingClientRectSpy = sinon.spy(host, 'getBoundingClientRect');\n\n host.dispatchEvent(new FocusEvent('focus'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(getBoundingClientRectSpy.called).to.be.true;\n });\n\n it('should show hover pane on focus', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n host.dispatchEvent(new FocusEvent('focus'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\n });\n\n it('should hide hover pane on blur', async () => {\n const host = await fixture<HostElement>(\n html`<host-element\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\n ></host-element>`,\n );\n\n host.dispatchEvent(new FocusEvent('focus'));\n // Need to wait a tick for the event handlers to run\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\n\n host.dispatchEvent(new FocusEvent('blur'));\n // Need to wait for the fade out transition\n await new Promise(resolve => {\n setTimeout(resolve, 150);\n });\n\n expect(host.controller?.getTemplate()).to.equal(nothing);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"hover-pane-controller.test.js","sourceRoot":"","sources":["../../../../test/tiles/hover/hover-pane-controller.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,mBAAmB,GAKpB,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAG+B,sBAAiB,GAAY,KAAK,CAAC;IA+ClE,CAAC;IAzCC,MAAM;QACJ,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC;IACn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E,KAAK,IAAI,EAAE;YAC9C,MAAM,IAAI,GAAG,MAAM,OAAO,CACxB,IAAI,CAAA;+BACmB,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;yBACpC,CAClB,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5C,oDAAoD;YACpD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1B,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB;YAEpF,IAAI,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3C,2CAA2C;YAC3C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\r\nimport { html, LitElement, nothing, TemplateResult } from 'lit';\r\nimport { customElement, property, query } from 'lit/decorators.js';\r\nimport {\r\n HoverPaneController,\r\n HoverPaneControllerInterface,\r\n HoverPaneControllerOptions,\r\n HoverPaneProperties,\r\n HoverPaneProviderInterface,\r\n} from '../../../src/tiles/hover/hover-pane-controller';\r\nimport type { TileHoverPane } from '../../../src/tiles/hover/tile-hover-pane';\r\nimport { TileModel } from '../../../src/models';\r\nimport sinon from 'sinon';\r\n\r\n@customElement('host-element')\r\nclass HostElement extends LitElement implements HoverPaneProviderInterface {\r\n @property({ type: Object }) controllerOptions?: HoverPaneControllerOptions;\r\n\r\n @property({ type: Boolean }) suppressHoverPane: boolean = false;\r\n\r\n @query('tile-hover-pane') hoverPane?: TileHoverPane;\r\n\r\n controller?: HoverPaneControllerInterface;\r\n\r\n render(): TemplateResult {\r\n return html` ${this.controller?.getTemplate()} `;\r\n }\r\n\r\n protected firstUpdated(): void {\r\n this.controller = new HoverPaneController(this, this.controllerOptions);\r\n }\r\n\r\n acquireFocus(): void {}\r\n\r\n releaseFocus(): void {}\r\n\r\n getHoverPane(): HTMLElement | undefined {\r\n return this.suppressHoverPane ? undefined : this.hoverPane;\r\n }\r\n\r\n getHoverPaneProps(): HoverPaneProperties {\r\n const tileModel = new TileModel({});\r\n tileModel.checked = false;\r\n tileModel.collectionFilesCount = 1;\r\n tileModel.collections = ['foo', 'bar'];\r\n tileModel.collectionSize = 1;\r\n tileModel.commentCount = 1;\r\n tileModel.contentWarning = false;\r\n tileModel.creators = ['foo', 'bar'];\r\n tileModel.favCount = 1;\r\n tileModel.identifier = 'foo';\r\n tileModel.itemCount = 1;\r\n tileModel.loginRequired = false;\r\n tileModel.mediatype = 'data';\r\n tileModel.subjects = ['foo', 'bar'];\r\n tileModel.title = 'foo';\r\n tileModel.viewCount = 1;\r\n\r\n return {\r\n model: tileModel,\r\n loggedIn: false,\r\n suppressBlurring: false,\r\n sortParam: null,\r\n };\r\n }\r\n}\r\n\r\ndescribe('Hover Pane Controller', () => {\r\n let oldMatchMedia: typeof window.matchMedia;\r\n let oldOnTouchStart: typeof window.ontouchstart;\r\n\r\n before(() => {\r\n oldMatchMedia = window.matchMedia;\r\n oldOnTouchStart = window.ontouchstart;\r\n window.matchMedia = () => ({ matches: true }) as MediaQueryList;\r\n window.ontouchstart = () => {};\r\n });\r\n\r\n after(() => {\r\n window.matchMedia = oldMatchMedia;\r\n window.ontouchstart = oldOnTouchStart;\r\n });\r\n\r\n it('should initially provide empty template', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element></host-element>`,\r\n );\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n it('should produce a hover pane template after mousemove, and hide it after mouseleave', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\r\n\r\n host.dispatchEvent(new MouseEvent('mouseleave'));\r\n // Need to wait for the fade out transition\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n it('should produce a hover pane template after mouseenter, even without mousemove', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(new MouseEvent('mouseenter'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\r\n });\r\n\r\n it('should immediately fade back in if mouse enters while fading out', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n // Enter the host element and wait for the show handlers to run\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n // Leave the host element so it begins fading out, but not all the way\r\n host.dispatchEvent(new MouseEvent('mouseleave'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 20);\r\n });\r\n\r\n // Re-enter the host element and wait long enough that it would disappear\r\n // if the hide were not cancelled\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\r\n });\r\n\r\n it('should flip hover pane if it would overflow the viewport', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(\r\n new MouseEvent('mousemove', { clientX: 800, clientY: 600 }),\r\n );\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n await host.updateComplete;\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\r\n expect(host.getHoverPane()?.getBoundingClientRect()?.right).to.be.lessThan(\r\n window.innerWidth,\r\n );\r\n expect(host.getHoverPane()?.getBoundingClientRect()?.bottom).to.be.lessThan(\r\n window.innerHeight,\r\n );\r\n });\r\n\r\n it('should not call showPopover when the hover pane is already open', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n // Show the pane and confirm the :popover-open state\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n await host.updateComplete;\r\n\r\n const pane = host.getHoverPane() as TileHoverPane;\r\n expect(pane?.matches(':popover-open')).to.be.true;\r\n\r\n const showPopoverSpy = sinon.spy(pane, 'showPopover');\r\n\r\n // Simulate the condition where the hover pane has finished its fade out\r\n // but its popover has not yet been hidden.\r\n (host.controller as unknown as { hoverPaneState: string }).hoverPaneState =\r\n 'hidden';\r\n\r\n // Subsequent mousemove tries to re-show the hover pane...\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 10);\r\n });\r\n await host.updateComplete;\r\n\r\n // ...but should NOT call showPopover() again\r\n expect(showPopoverSpy.called).to.be.false;\r\n expect(host.getHoverPane()?.matches(':popover-open')).to.be.true;\r\n });\r\n\r\n it('should gracefully handle undefined hover pane from host element', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ?suppressHoverPane=${true}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\r\n\r\n host.dispatchEvent(new MouseEvent('mouseleave'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 20);\r\n });\r\n\r\n host.dispatchEvent(new MouseEvent('mousemove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n host.dispatchEvent(new MouseEvent('mouseleave'));\r\n // Need to wait for the fade out transition\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n describe('Touch & long-press', () => {\r\n const getTouchStartEvent = (host: EventTarget) =>\r\n new TouchEvent('touchstart', {\r\n touches: [new Touch({ identifier: 0, target: host })],\r\n });\r\n\r\n it('should produce a hover pane after long press', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{\r\n showDelay: 0,\r\n longPressDelay: 0,\r\n enableLongPress: true,\r\n }}\r\n ></host-element>`,\r\n );\r\n\r\n // Touch the host element and wait for the long press handlers to run\r\n host.dispatchEvent(getTouchStartEvent(host));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\r\n });\r\n\r\n it('should cancel a long press by moving', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{\r\n showDelay: 0,\r\n longPressDelay: 100,\r\n enableLongPress: true,\r\n }}\r\n ></host-element>`,\r\n );\r\n\r\n // Touch the host element\r\n host.dispatchEvent(getTouchStartEvent(host));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n // Move the touch point, cancelling the long press\r\n host.dispatchEvent(new TouchEvent('touchmove'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n it('should cancel a long press by ending touch', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{\r\n showDelay: 0,\r\n longPressDelay: 100,\r\n enableLongPress: true,\r\n }}\r\n ></host-element>`,\r\n );\r\n\r\n // Touch the host element\r\n host.dispatchEvent(getTouchStartEvent(host));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n // Lift the touch point, cancelling the long press\r\n host.dispatchEvent(new TouchEvent('touchend'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n it('should cancel a long press by cancelling touch (e.g., too many touch points)', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{\r\n showDelay: 0,\r\n longPressDelay: 100,\r\n enableLongPress: true,\r\n }}\r\n ></host-element>`,\r\n );\r\n\r\n // Touch the host element\r\n host.dispatchEvent(getTouchStartEvent(host));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n // Cancel the touch point, also cancelling the long press\r\n host.dispatchEvent(new TouchEvent('touchcancel'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n\r\n it('should close the hover pane on mobile when touching the backdrop', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{\r\n showDelay: 0,\r\n hideDelay: 0,\r\n longPressDelay: 0,\r\n enableLongPress: true,\r\n mobileBreakpoint: 9999, // Ensure we get the mobile view\r\n }}\r\n ></host-element>`,\r\n );\r\n\r\n // Touch the host element\r\n host.dispatchEvent(getTouchStartEvent(host));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing);\r\n\r\n await host.updateComplete;\r\n\r\n // Touch the backdrop\r\n host.shadowRoot\r\n ?.querySelector('#touch-backdrop')\r\n ?.dispatchEvent(new TouchEvent('touchstart'));\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n });\r\n\r\n describe('keyboard accessibility', () => {\r\n it('should call host getBoundingClientRect if anchor is host', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n const getBoundingClientRectSpy = sinon.spy(host, 'getBoundingClientRect');\r\n\r\n host.dispatchEvent(new FocusEvent('focus'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(getBoundingClientRectSpy.called).to.be.true;\r\n });\r\n\r\n it('should show hover pane on focus', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(new FocusEvent('focus'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\r\n });\r\n\r\n it('should hide hover pane on blur', async () => {\r\n const host = await fixture<HostElement>(\r\n html`<host-element\r\n .controllerOptions=${{ showDelay: 0, hideDelay: 0 }}\r\n ></host-element>`,\r\n );\r\n\r\n host.dispatchEvent(new FocusEvent('focus'));\r\n // Need to wait a tick for the event handlers to run\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 0);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).not.to.equal(nothing); // Is a TemplateResult\r\n\r\n host.dispatchEvent(new FocusEvent('blur'));\r\n // Need to wait for the fade out transition\r\n await new Promise(resolve => {\r\n setTimeout(resolve, 150);\r\n });\r\n\r\n expect(host.controller?.getTemplate()).to.equal(nothing);\r\n });\r\n });\r\n});\r\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The Internet Archive Collection Browser.",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Internet Archive",
6
- "version": "4.5.1",
6
+ "version": "4.5.2",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {