Class TJSPosition
Implements
Index
Constructors
Accessors
Methods
Constructors
constructor
- new TJSPosition(parentOrOptions?, options?): TJSPosition
Parameters
Optional
parentOrOptions: PositionParent | Partial<OptionsCtor & TJSPositionDataExtra>A potential parent element or object w/
elementTarget
accessor. You may also forego setting the parent and pass in the options object.Optional
options: Partial<OptionsCtor & TJSPositionDataExtra>The options object.
Returns TJSPosition
Accessors
animate
- get animate(): AnimationAPI
Returns the animation API.
Returns AnimationAPI
Animation API.
dimension
element
- get element(): HTMLElement
Returns the current HTMLElement being positioned.
Returns HTMLElement
Current HTMLElement being positioned.
elementUpdated
enabled
- get enabled(): boolean
Returns the enabled state.
Returns boolean
Enabled state.
- set enabled(enabled): void
Sets the enabled state.
Parameters
- enabled: boolean
New enabled state.
Returns void
- enabled: boolean
height
- get height(): number | "auto" | "inherit"
Returns number | "auto" | "inherit"
height
- set height(height): void
Parameters
- height: number | "auto" | "inherit"
Returns void
left
- get left(): number
Returns number
left
- set left(left): void
Parameters
- left: string | number
Returns void
maxHeight
- get maxHeight(): number
Returns number
maxHeight
- set maxHeight(maxHeight): void
Parameters
- maxHeight: string | number
Returns void
maxWidth
- get maxWidth(): number
Returns number
maxWidth
- set maxWidth(maxWidth): void
Parameters
- maxWidth: string | number
Returns void
minHeight
- get minHeight(): number
Returns number
minHeight
- set minHeight(minHeight): void
Parameters
- minHeight: string | number
Returns void
minWidth
- get minWidth(): number
Returns number
minWidth
- set minWidth(minWidth): void
Parameters
- minWidth: string | number
Returns void
parent
- get parent(): PositionParent
Returns the associated TJSPositionTypes.PositionParent instance.
Returns PositionParent
The current position parent instance.
- set parent(parent): void
Sets the associated TJSPositionTypes.PositionParent instance. Resets the style cache and default data.
Parameters
- parent: PositionParent
A PositionParent instance or undefined to disassociate
Returns void
- parent: PositionParent
rotateX
- get rotateX(): number
Returns number
rotateX
- set rotateX(rotateX): void
Parameters
- rotateX: string | number
Returns void
rotateY
- get rotateY(): number
Returns number
rotateY
- set rotateY(rotateY): void
Parameters
- rotateY: string | number
Returns void
rotateZ
- get rotateZ(): number
Returns number
rotateZ
- set rotateZ(rotateZ): void
Parameters
- rotateZ: string | number
Returns void
rotation
- get rotation(): number
Returns number
alias for rotateZ
- set rotation(rotateZ): void
Parameters
- rotateZ: string | number
alias for rotateZ
Returns void
- rotateZ: string | number
scale
- get scale(): number
Returns number
scale
- set scale(scale): void
Parameters
- scale: string | number
Returns void
state
- get state(): PositionStateAPI
Returns the state API.
Returns PositionStateAPI
TJSPosition state API.
stores
- get stores(): TJSPositionTypes.Stores
Returns the derived writable stores for individual data variables.
Returns TJSPositionTypes.Stores
Derived / writable stores.
top
- get top(): number
Returns number
top
- set top(top): void
Parameters
- top: string | number
Returns void
transform
- get transform(): TransformData
Returns the transform data for the readable store.
Returns TransformData
Transform Data.
transformOrigin
- get transformOrigin(): TransformOrigin
Returns TransformOrigin
transformOrigin
- set transformOrigin(transformOrigin): void
Parameters
- transformOrigin: TransformOrigin
Returns void
translateX
- get translateX(): number
Returns number
translateX
- set translateX(translateX): void
Parameters
- translateX: string | number
Returns void
translateY
- get translateY(): number
Returns number
translateY
- set translateY(translateY): void
Parameters
- translateY: string | number
Returns void
translateZ
- get translateZ(): number
Returns number
translateZ
- set translateZ(translateZ): void
Parameters
- translateZ: string | number
Returns void
validators
- get validators(): ValidatorAPI
Returns the validators.
Returns ValidatorAPI
validators.
width
- get width(): number | "auto" | "inherit"
Returns number | "auto" | "inherit"
width
- set width(width): void
Parameters
- width: number | "auto" | "inherit"
Returns void
zIndex
- get zIndex(): number
Returns number
z-index
- set zIndex(zIndex): void
Parameters
- zIndex: string | number
Returns void
Static
Animate
- get Animate(): AnimationGroupAPI
Returns AnimationGroupAPI
Public Animation API.
Static
Data
- get Data(): TJSPositionDataConstructor
Returns TJSPositionDataConstructor
TJSPositionData constructor.
Static
Initial
- get Initial(): Readonly<PositionInitial>
Returns Readonly<PositionInitial>
TJSPosition default initial helpers.
Static
SystemBase
- get SystemBase(): SystemBaseConstructor
Returns SystemBaseConstructor
SystemBase
constructor.
Static
TransformData
- get TransformData(): TransformDataConstructor
Returns TJSTransformData class / constructor.
Returns TransformDataConstructor
TransformData class / constructor.
Static
transformOrigins
- get transformOrigins(): readonly TransformOrigin[]
Returns a list of supported transform origins.
Returns readonly TransformOrigin[]
The supported transform origin strings.
Static
Validators
- get Validators(): Readonly<PositionValidators>
Returns default validators.
Returns Readonly<PositionValidators>
Available validators.
Methods
get
- get(data?, options?): Partial<TJSPositionData>
Assigns current position data to given object
data
object. By default,null
position data is not assigned. Other options allow configuration of the data assigned including setting default numeric values for any properties that are null.Parameters
Optional
data: objectTarget to assign current position data.
Optional
options: OptionsGetDefines options for specific keys and substituting null for numeric default values. By default, nullable keys are included.
Returns Partial<TJSPositionData>
Passed in object with current position data.
set
- set(position?, options?): TJSPosition
All calculation and updates of position are implemented in TJSPosition. This allows position to be fully reactive and in control of updating inline styles for a connected HTMLElement.
The initial set call with a target element will always set width / height as this is necessary for correct calculations.
When a target element is present updated styles are applied after validation. To modify the behavior of set implement one or more validator functions and add them via the validator API available from TJSPosition.validators.
Updates to any target element are decoupled from the underlying TJSPosition data. This method returns this instance that you can then await on the target element inline style update by using TJSPosition.elementUpdated.
Relative updates to any property of TJSPositionData are possible by specifying properties as strings. This string should be in the form of '+=', '-=', or '*=' and float / numeric value. IE '+=0.2'. TJSPosition.set will apply the
addition
,subtraction
, ormultiplication
operation specified against the current value of the given property. Please see Data.TJSPositionDataRelative for a detailed description.Parameters
Optional
position: TJSPositionDataRelativeTJSPosition data to set.
Optional
options: OptionsSetAdditional options.
Returns TJSPosition
This TJSPosition instance.
subscribe
- subscribe(handler): Unsubscriber
Parameters
- handler: Subscriber<Readonly<TJSPositionData>>
Callback function that is invoked on update / changes. Receives a readonly copy of the TJSPositionData.
Returns Unsubscriber
Unsubscribe function.
- handler: Subscriber<Readonly<TJSPositionData>>
toJSON
- toJSON(): TJSPositionData
Returns TJSPositionData
Current position data.
update
- update(updater): void
Provides the Writable store
update
method. Receive and return a TJSPositionData instance to update the position state. You may manipulate numeric properties by providing relative adjustments described in TJSPositionDataRelative.Parameters
- updater: Updater<TJSPositionDataRelative>
Returns void
Static
copyData
- copy
Data (source, target?): TJSPositionData Convenience to copy from source to target of two TJSPositionData like objects. If a target is not supplied a new TJSPositionData instance is created.
Parameters
- source: Partial<TJSPositionData>
The source instance to copy from.
Optional
target: TJSPositionDataTarget TJSPositionData like object; if one is not provided a new instance is created.
Returns TJSPositionData
The target instance with all TJSPositionData fields.
- source: Partial<TJSPositionData>
Static
duplicate
- duplicate(position, options?): TJSPosition
Returns a duplicate of a given position instance copying any options and validators. The position parent is not copied and a new one must be set manually via the TJSPosition.parent setter.
Parameters
- position: TJSPosition
A position instance.
Optional
options: Partial<OptionsCtor & TJSPositionDataExtra>Unique new options to set.
Returns TJSPosition
A duplicate position instance.
- position: TJSPosition
Provides an advanced compound store for positioning elements dynamically including an optimized pipeline for updating an associated element. Essential tweening / animation is supported in addition to a validation API to constrain positional updates.