Skip to content

generateApplicationPosition

Jason Godesky edited this page Jul 17, 2026 · 2 revisions

generateApplicationPosition is a method that returns the Partial<foundry.types.ApplicationPosition> you need to pass to setPosition or the position property of DEFAULT_OPTIONS when you create an ApplicationV2.

Parameters

options: ApplicationPositionOptions

An options object. Each property is optional.

height?: number | 'auto'

'auto' or a number greater than or equal to 1 is passed through. A number less than 1 is used to calculate the height as a percentage of the window height (e.g., 0.5 would calculate the height as half the window’s inner height).

Default: 0.5

width?: number | 'auto'

'auto' or a number greater than or equal to 1 is passed through. A number less than 1 is used to calculate the width as a percentage of the window width (e.g., 0.5 would calculate the width as half the window’s inner width).

Default: 0.5

left?: number

Distance in pixels from the left edge of the window where the application should appear.

Default: The panel is centered horizontally in the window.

top?: number

Distance in pixels from the top edge of the window where the application should appear.

Default: The panel is centered vertically in the window.

viewport?: { innerHeight: number, innerWidth: number }

The viewport in which the application will appear. Useful for testing, but probably best left to the default in production.

Default: window

Returns

A Partial<foundry.types.ApplicationPosition> that you can pass to setPosition or the position property of DEFAULT_OPTIONS when you create an ApplicationV2.

Examples

import { generateApplicationPosition } from '@revolutionarygamesco/common-foundryvtt'

new MyApplication({
  position: generateApplicationPosition({ height: 2 / 3, width: 1 / 2 })
}).render(true)

Clone this wiki locally