```
* @summary Convert the coordinates of the touch to some other frame of reference.
* @detail (target?,snap?)
*/
αfit(): void;
αfit(start: Length, end: Length, snap?: number): void;
αfit(target: ModifierElementTarget): void;
αfit(target: ModifierElementTarget, snap?: number): void;
αfit(target: ModifierElementTarget, snap?: number): void;
αfit(target: ModifierElementTarget, start: Length, end: Length, snap?: number): void;
/**
* Just like @touch.fit but without clamping x,y to the bounds of the
* target.
* @detail (target?, ax?, ay?)
*/
αreframe(): void;
αreframe(start: Length, end: Length, snap?: number): void;
αreframe(context: Element | string, snap?: number): void;
αreframe(context: Element | string, start: Length, end: Length, snap?: number): void;
/**
* Allow pinning the touch to a certain point in an element, so that
* all future x,y values are relative to this pinned point.
* @detail (target?, ax?, ay?)
*/
αpin(): void;
αpin(target: ModifierElementTarget): void;
αpin(anchorX: number, anchorY?: number): void;
αpin(target: ModifierElementTarget, anchorX?: number, anchorY?: number): void;
/**
* Round the x,y coordinates with an optional accuracy
* @detail (to = 1)
*/
αround(nearest?: number): void;
/**
* Add an html class to target for at least 250ms
* If the callback returns a promise, the class
* will not be removed until said promise has resolved
* @param name the class to add
* @param target the element on which to add the class. Defaults to the element itself
* @detail (name,target?)
* */
αflag(name: string, target?: FlagTarget): void;
/**
* Add an html class to target for at least 250ms
* If the callback returns a promise, the class
* will not be removed until said promise has resolved
* @param target the element on which to add the class. Defaults to the element itself
* @deprecated
**/
αflagΞname(target?: FlagTarget): void;
/**
* Only trigger handler if event.target matches selector
* @detail (selector)
* */
αsel(selector: string): boolean;
/**
Tells the browser that the default action should not be taken. The event will still continue to propagate up the tree. See Event.preventDefault()
@see https://imba.io/events/event-modifiers#core-prevent
*/
αprevent(): void;
/**
Stops the event from propagating up the tree. Event listeners for the same event on nodes further up the tree will not be triggered. See Event.stopPropagation()
*/
αstop(): void;
/**
Prevents default action & stops event from bubbling.
*/
αtrap(): void;
/**
* The `self` event modifier is a handy way of reacting to events only when they are clicked on the actual element you are interacting with and not, for example, a child element. This can be useful for things like modal wrappers when you only want to react when clicking directly.
* @summary Only trigger handler if event.target is the element itself
*/
αself(): boolean;
/**
* @summary Don't trigger imba.commit from this event handler
*/
αsilent(): void;
/**
* @summary Suppress pointer events on all other elements
*/
αlock(): void;
/**
* Only trigger condition is truthy
* @detail (condition)
* */
αif(condition: unknown): boolean;
}
type IntersectRoot = Element | Document;
type IntersectOptions = {
rootMargin?: string;
root?: IntersectRoot;
thresholds?: number[];
}
/**
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is a [well-supported](https://caniuse.com/#feat=intersectionobserver) API in modern browsers. It provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. Imba adds a simplified abstraction on top of this via the custom `@intersect` event.
#### Syntax
```imba
# Will only trigger when intersection ratio increases
# Will only trigger when element is more than 50% visible
```
#### Parameters
The `@intersect` events accepts several arguments. You can pass in an object with the same [root](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root), [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin), and [threshold](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/threshold) properties supported by [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver).
```imba
# default options
```
For convenience, imba will convert certain arguments into options. A single number between 0 and 1 will map to the [threshold](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/threshold) option:
```imba
# n 0-1 adds single threshold at n visibility
# {threshold: 0}
# {threshold: 0.5}
# {threshold: 1.0}
```
Any number above 1 will add n thresholds, spread evenly:
```imba
# {threshold: [0,1]}
# {threshold: [0,0.5,1]}
# {threshold: [0,0.25,0.5,0.75,1]}
# ... and so forth
```
An element will map to the [root](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root) option:
```imba
# {root: frame}
# {root: frame, threshold: [0,0.5,1]}
```
A string will map to the [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin) option:
```imba
# {rootMargin: "20px 10px"}
```
* @custom
*/
class IntersectEvent extends Event {
/**
The `out` modifier stops the handler unless intersectionRatio has *increased*.
#### Syntax
```imba
# Will only trigger when intersection ratio increases
# Will only trigger when element is more than 50% visible
```
@summary Stop handling unless intersectionRatio has increased.
*/
αin(): boolean;
/**
*
The `out` modifier stops the handler unless intersectionRatio has *decreased*.
#### Syntax
```imba
# Will only trigger when element starts intersecting
# Will trigger whenever any part of the div is hidden
```
@summary Stop handling unless intersectionRatio has decreased.
*/
αout(): boolean;
/**
The css modifier sets a css variable --ratio on the event target with the current ratio.
@summary Set css variable `--ratio` to the intersectionRatio.
*/
αcss(): void;
/**
* Will add a class to the DOM element when intersecting
* @param name The class-name to add
*/
αflag(name: string): void;
/**
* Configuring
* @param root reference to the parent
* @param thresholds 0-1 for a single threshold, 2+ for n slices
*/
αoptions(root?: IntersectRoot, thresholds?: number): void;
αoptions(thresholds?: number): void;
αoptions(rootMargin: string, thresholds?: number): void;
αoptions(rootMargin: string, thresholds?: number): void;
αoptions(options: IntersectOptions): void;
/**
* The raw IntersectionObserverEntry
*
*/
entry: IntersectionObserverEntry;
/**
* Ratio of the intersectionRect to the boundingClientRect
*
*/
ratio: number;
/**
* Difference in ratio since previous event
*
*/
delta: number;
}
class HotkeyEvent extends Event {
/**
*
* @param pattern string following pattern from mousetrap
* @see https://craig.is/killing/mice
*/
αoptions(pattern:string): void;
/**
* Also trigger when input,textarea or a contenteditable is focused
* @deprecated Use `force` instead
*/
αcapture(): void;
/**
* Trigger even if outside of the originating hotkey group
*/
αglobal(): void;
/**
* Trigger only if KeyboardEvent originates from this element or a child.
*/
αlocal(): void;
/**
* Allow subsequent hotkey handlers for the same combo
* and don't automatically prevent default behaviour of originating
* keyboard event
*/
αpassive(): void;
/**
* Also trigger when input,textarea or a contenteditable is focused
*/
αforce(): void;
/**
* Allow the handler to trigger multiple times while user
* keeps pressing the key combination.
*/
αrepeat(): void;
/**
* The KeyboardEvent responsible for this HotkeyEvent
*
*/
readonly originalEvent: KeyboardEvent;
/**
* The combo for the event
*
*/
readonly combo: string;
}
/**
* The [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) interface reports changes to the dimensions of an Element's content or border box. It has [good browser support](https://caniuse.com/#feat=resizeobserver) and is very useful in a wide variety of usecases. ResizeObserver avoids infinite callback loops and cyclic dependencies that are often created when resizing via a callback function. It does this by only processing elements deeper in the DOM in subsequent frames.
* @custom
*/
class ResizeEvent extends UIEvent {
/** Width of the resized element */
readonly width: number;
/** Height of the resized element */
readonly height: number;
/** contentRect from the ResizeObserverEntry */
readonly rect: DOMRectReadOnly;
/** the raw ResizeObserverEntry */
readonly entry: ResizeObserverEntry;
/**
The css modifier sets css variables (or units) to the width/height
of the resized element
@summary Set css variables for width / height of resized element
*/
αcss(wunit?:string, hunit?:string, selector?: FlagTarget): void;
}
class SelectionEvent extends Event {
detail: {
start: number;
end: number;
}
}
}
interface GlobalEventHandlersEventMap {
"touch": imba.Touch;
"intersect": imba.IntersectEvent;
"selection": imba.SelectionEvent;
"hotkey": imba.HotkeyEvent;
"resize": imba.ResizeEvent;
"__unknown": CustomEvent;
}
interface HTMLElementEventMap {
"resize": imba.ResizeEvent;
}
interface ImbaEvents {
/**
* The loading of a resource has been aborted.
*
*/
abort: Event;
animationcancel: AnimationEvent;
/**
* A CSS animation has completed.
*
*/
animationend: AnimationEvent;
/**
* A CSS animation is repeated.
*
*/
animationiteration: AnimationEvent;
/**
* A CSS animation has started.
*
*/
animationstart: AnimationEvent;
auxclick: MouseEvent;
/**
* An element has lost focus (does not bubble).
*
*/
blur: FocusEvent;
cancel: Event;
/**
* The user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.
*
*/
canplay: Event;
/**
* The user agent can play the media up to its end without having to stop for further buffering of content.
*
*/
canplaythrough: Event;
/**
* The change event is fired for ` `, ``, and `