UNPKG

32.8 kBTypeScriptView Raw
1
2type FlagTarget = Element | Document | string;
3
4interface Event {
5 /**
6 Tells the browser that the default action should not be taken. The event will still continue to propagate up the tree. See Event.preventDefault()
7 @see https://imba.io/events/event-modifiers#core-prevent
8 */
9 αprevent(): void;
10 /**
11 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()
12 */
13 αstop(): void;
14
15 /**
16 Prevents default action & stops event from bubbling.
17 */
18 αtrap(): void;
19
20 /**
21 * Indicates that the listeners should be invoked at most once. The listener will automatically be removed when invoked.
22 */
23 αonce(): void;
24
25 /**
26 * Indicating that events of this type should be dispatched to the registered listener before being dispatched to tags deeper in the DOM tree.
27 */
28 αcapture(): void;
29
30 /**
31 * Indicates that the listener will never call preventDefault(). If a passive listener does call preventDefault(), the user agent will do nothing other than generate a console warning. This is useful for optimal performance while scrolling etc.
32 *
33 * @summary indicates that the listener will never call preventDefault()
34 */
35 αpassive(): void;
36
37 /**
38 * By default, Imba will re-render all scheduled tags after any *handled* event. So, Imba won't re-render your application if you click an element that has no attached handlers, but if you've added a `@click` listener somewhere in the chain of elements, `imba.commit` will automatically be called after the event has been handled.
39
40 This is usually what you want, but it is useful to be able to override this, especially when dealing with `@scroll` and other events that might fire rapidly.
41
42 #### Syntax
43 ```imba
44 # Will only trigger when intersection ratio increases
45 <div @click.silent=handler>
46 # Will only trigger when element is more than 50% visible
47 <div @intersect(0.5).in=handler>
48 ```
49 * @summary Don't trigger imba.commit from this event handler
50 */
51 αsilent(): void;
52
53 /**
54 * Calls `imba.commit` when event is handled. This will happen by default for all events with a handler (so `.commit` is superflous in the case of `<@event.commit=handler>`). There are cases however where you just want to make sure the interface is updated when certain events are triggered, without actually doing anything in response to the event. Ie. if you have an audio-element and you render something based on the `playState` of said element, you might want to commit for certain events: `<audio @ended.commit @play.commit @pause.commit>`.
55 *
56 * @summary indicates that the listener will call imba.commit
57 */
58 αcommit(): void;
59
60 /** The wait modifier delays the execution of subsequent modifiers and callback. It defaults to wait for 250ms, which can be overridden by passing a number or time as the first/only argument.
61 *
62 * @summary pause handler for `n` duration (default 250ms)
63 * @detail (time = 500ms)
64 */
65 αwait(time?: Time): void;
66
67 /**
68 * The `throttle` modifier ensures the handler is called at most every `n` milliseconds (defaults to 500ms). This can be useful for events that fire very rapidly like `@scroll`, `@pointermove` etc.
69 *
70 * See `@event.cooldown` and `@event.debounce`.
71 * @detail (time = 500ms)
72 * @summary ensures that handler triggers at most every `n` seconds
73 */
74 αthrottle(time?: Time): void;
75
76 /**
77 * The `cooldown` modifier ensures the handler is called at most every `n` milliseconds (defaults to 500ms). This can be useful for events that fire very rapidly like `@scroll`, `@pointermove` etc.
78 *
79 * See `@event.throttle` and `@event.debounce`.
80 *
81 * @detail (time = 500ms)
82 * @summary disable handler for a duration after trigger
83 */
84 αcooldown(time?: Time): void;
85
86 /**
87 * The `debounce` modifier ensures that a minimum amount of time has elapsed after the user stops interacting and before calling the handler. This is especially useful, for example, when querying an API and not wanting to perform a request on every keystroke.
88 *
89 * See `@event.cooldown` and `@event.throttle`.
90 * @detail (time = 500ms)
91 * @summary dont trigger until no events has been handled for `n` time
92 */
93 αdebounce(time?: Time): void;
94
95 /**
96 Stops handling unless event is trusted
97 @see https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted
98 */
99 αtrusted(): boolean;
100
101 /**
102 * 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.
103 * @summary Handle if event.target is the element itself
104 */
105 αself(): boolean;
106
107 /**
108 * Only trigger handler if event.target matches selector
109 * @detail (selector)
110 * */
111 αsel(selector: string): boolean;
112
113 /**
114 * Only trigger handler if event.target.closest(selector) returns a match
115 * @detail (selector)
116 * */
117 αclosest(selector: string): boolean;
118
119 /**
120 * Only trigger condition is truthy
121 * @detail (condition)
122 * */
123 αif(condition: unknown): boolean;
124
125 /**
126 * Trigger a custom event via this handler
127 * @param name The name of the event to trigger
128 * @param detail Data associated with the event
129 * @detail (name,detail = {})
130 * */
131 αemit(name: string, detail?: any): void;
132 /**
133 * Trigger a custom event via this handler
134 * @param detail Data associated with the event
135 * @deprecated
136 * */
137 αemitΞname(detail?: any): void;
138
139 /**
140 * Add an html class to target for at least 250ms
141 * If the callback returns a promise, the class
142 * will not be removed until said promise has resolved
143 * @param name the class to add
144 * @param target the element on which to add the class. Defaults to the element itself
145 * @detail (name,target?)
146 * */
147 αflag(name: string, target?: FlagTarget): void;
148
149 /**
150 * Add an html class to target for at least 250ms
151 * If the callback returns a promise, the class
152 * will not be removed until said promise has resolved
153 * @param target the element on which to add the class. Defaults to the element itself
154 * @deprecated
155 **/
156 αflagΞname(target?: FlagTarget): void;
157
158 /**
159 * Logs to console
160 * @detail (...data)
161 */
162 αlog(...data: any[]): void;
163
164 /**
165 * Handle if event originates from outside the literal container of the `<global>` teleport.
166 * This modifier is only supported on `<global>` listeners.
167 *
168 * @summary Handle if event originates from outside the handler
169 */
170 αoutside(): void;
171}
172
173interface MouseEvent {
174 /**
175 * Handle if ctrlKey is pressed
176 *
177 */
178 αctrl(): boolean;
179
180 /**
181 * Handle if altKey is pressed
182 *
183 */
184 αalt(): boolean;
185
186 /**
187 * Handle if shiftKey is pressed
188 *
189 */
190 αshift(): boolean;
191
192 /**
193 * Handle if metaKey is pressed
194 *
195 */
196 αmeta(): boolean;
197
198 /**
199 * Apple uses the ⌘ key while others use the Ctrl key for many keyboard shortcuts
200 * and features like (⌘ or Ctrl)+click for opening a link in a new tab.
201 * This modifier unifies the logic and is essentially an alias for `.meta` on mac,
202 * and `.ctrl` for all other platforms.
203 *
204 * @summary Handle if metaKey (on mac) or ctrlKey (other platforms) is pressed
205 *
206 */
207 αmod(): boolean;
208
209 /**
210 * Handle if middle button is pressed
211 *
212 */
213 αmiddle(): boolean;
214
215 /**
216 * Handle if left/primary button is pressed
217 *
218 */
219 αleft(): boolean;
220
221 /**
222 * Handle if right button is pressed
223 *
224 */
225 αright(): boolean;
226}
227
228interface KeyboardEvent {
229 /**
230 * Handle if enter key is pressed
231 *
232 */
233 αenter(): boolean;
234
235 /**
236 * Handle if left key is pressed
237 *
238 */
239 αleft(): boolean;
240
241 /**
242 * Handle if right key is pressed
243 *
244 */
245 αright(): boolean;
246
247 /**
248 * Handle if up key is pressed
249 *
250 */
251 αup(): boolean;
252
253 /**
254 * Handle if down key is pressed
255 *
256 */
257 αdown(): boolean;
258
259 /**
260 * Handle if tab key is pressed
261 *
262 */
263 αtab(): boolean;
264
265 /**
266 * Handle if esc key is pressed
267 *
268 */
269 αesc(): boolean;
270
271 /**
272 * Handle if space key is pressed
273 *
274 */
275 αspace(): boolean;
276
277 /**
278 * Handle if del key is pressed
279 *
280 */
281 αdel(): boolean;
282
283 /**
284 * Handle if keyCode == code
285 * @detail (code)
286 */
287 αkey(code:number): boolean;
288}
289
290interface PointerEvent {
291 /**
292 * @summary Handle if the event was generated by a mouse device.
293 */
294 αmouse(): boolean;
295
296 /**
297 * @summary Handle if the event was generated by a pen or stylus device.
298 */
299 αpen(): boolean;
300
301 /**
302 * @summary Handle if the event was generated by a touch, such as a finger.
303 */
304 αtouch(): boolean;
305
306 /**
307 * Only when pressure is at least amount (defaults to 0.5)
308 * @detail (threshold=0.5)
309 */
310 αpressure(amount?:number): boolean;
311}
312
313interface DragEvent {
314
315}
316
317type ModifierElementTarget = Element | string;
318
319declare namespace imba {
320
321 /**
322 * To make it easier and more fun to work with touches, Imba includes a custom `@touch` event that combines `@pointerdown` -> `@pointermove` -> `@pointerup` in one convenient handler, with modifiers for commonly needed functionality.
323 * @custom
324 */
325 class Touch {
326
327 /** The final X coordinate of the pointer (after modifiers) */
328 x: number;
329
330 /** The final Y coordinate of the pointer (after modifiers) */
331 y: number;
332
333 /** The horizontal movement of the pointer (after modifiers) */
334 dx: number;
335
336 /** The vertical movement of the pointer (after modifiers). */
337 dy: number;
338
339 target: Element;
340
341 /** The X coordinate of the pointer in local (DOM content) coordinates. */
342 get clientX(): number;
343
344 /** The Y coordinate of the mouse pointer in local (DOM content) coordinates. */
345 get clientY(): number;
346
347 /** True if touch is still active */
348 get activeΦ(): boolean;
349
350 /** True if touch has ended */
351 get endedΦ(): boolean;
352
353 /** Returns true if the `control` key was down when the mouse event was fired. */
354 get ctrlKey(): boolean;
355
356 /** Returns true if the `alt` key was down when the mouse event was fired. */
357 get altKey(): boolean;
358
359 /** Returns true if the `shift` key was down when the mouse event was fired. */
360 get shiftKey(): boolean;
361
362 /** Returns true if the `shift` key was down when the mouse event was fired. */
363 get metaKey(): boolean;
364
365 /** Indicates the device type that caused the event (mouse, pen, touch, etc.) */
366 get pointerType(): string;
367
368 /**
369 The identifier is unique, being different from the identifiers of all other active pointer events. Since the value may be randomly generated, it is not guaranteed to convey any particular meaning.
370
371 @summary A unique identifier for the pointer causing the event.
372 * */
373 get pointerId(): number;
374
375 /**
376 * This guard will break the chain unless the touch has moved more than threshold. Once this threshold has been reached, all subsequent updates of touch will pass through. The element will also activate the `@move` pseudostate during touch - after threshold is reached.
377 * #### Syntax
378 ```imba
379 <div @touch.moved(threshold=4px, dir='any')>
380 ```
381 * @summary Only when touch has moved more than threshold
382 * @detail (threshold = 4px, dir = 'any')
383 */
384 αmoved(threshold?: Length, dir?: string): boolean;
385
386 /**
387 * Only when touch has moved left or right more than threshold
388 * @detail (threshold = 4px)
389 * @deprecated
390 */
391 αmovedΞx(threshold?: Length): boolean;
392
393 /**
394 * Only when touch has moved up or down more than threshold
395 * @detail (threshold = 4px)
396 * @deprecated
397 */
398 αmovedΞy(threshold?: Length): boolean;
399
400 /**
401 * Only when touch has moved up more than threshold
402 * @detail (threshold = 4px)
403 ** @deprecated
404 */
405 αmovedΞup(threshold?: Length): boolean;
406
407 /**
408 * Only when touch has moved down more than threshold
409 * @detail (threshold = 4px)
410 * @deprecated
411 */
412 αmovedΞdown(threshold?: Length): boolean;
413
414 /**
415 * Only when touch has moved left more than threshold
416 * @detail (threshold = 4px)
417 * @deprecated
418 */
419 αmovedΞleft(threshold?: Length): boolean;
420
421 /**
422 * Only when touch has moved right more than threshold
423 * @detail (threshold = 4px)
424 * @deprecated
425 */
426 αmovedΞright(threshold?: Length): boolean;
427
428 /**
429 * This guard will break the chain unless the touch has been held for a duration.
430 * If the pointer moves more than 5px before the modifier activates, the handler will
431 * essentially be cancelled.
432 * #### Syntax
433 ```imba
434 <div @touch.hold(duration=250ms)>
435 ```
436 * @summary Only start handling after pressing and holding still
437 * @detail (duration = 250ms)
438 */
439 αhold(threshold?: Length, dir?: string): boolean;
440
441 /**
442 * A convenient touch modifier that takes care of updating the x,y values of some data during touch. When touch starts sync will remember the initial x,y values and only add/subtract based on movement of the touch.
443 *
444 * #### Syntax
445 ```imba
446 <div @touch.sync(target, xprop='x', yprop='y')>
447 ```
448 * @summary Sync the x,y properties of touch to another object
449 * @detail (data, xProp?, yProp?)
450 */
451 αsync(data: object, xName?: string | null, yName?: string | null): boolean;
452
453 /**
454 * Sets the x and y properties of object to the x and y properties of touch.
455 *
456 * @see https://imba.io/events/touch-events#modifiers-apply
457 * @detail (data, xProp?, yProp?)
458 */
459 αapply(data: object, xName?: string | null, yName?: string | null): boolean;
460
461 /**
462 * A very common need for touches is to convert the coordinates of the touch to some other frame of reference. When dragging you might want to make x,y relative to the container. For a custom slider you might want to convert the coordinates from pixels to relative offset of the slider track. There are loads of other scenarios where you'd want to convert the coordinates to some arbitrary scale and offset. This can easily be achieved with fitting modifiers.
463 * #### Syntax
464 ```imba
465 <div @touch.fit> # make x,y relative to the element
466 <div @touch.fit(start,end,snap?)>
467 <div @touch.fit(target)> # make x,y relative to a target element
468 <div @touch.fit(target,start,end,snap?)>
469 <div @touch.fit(target,[xstart,ystart],[xend,yend],snap?)>
470 ```
471 * @summary Convert the coordinates of the touch to some other frame of reference.
472 * @detail (target?,snap?)
473 */
474 αfit(): void;
475 αfit(start: Length, end: Length, snap?: number): void;
476 αfit(target: ModifierElementTarget): void;
477 αfit(target: ModifierElementTarget, snap?: number): void;
478 αfit(target: ModifierElementTarget, snap?: number): void;
479 αfit(target: ModifierElementTarget, start: Length, end: Length, snap?: number): void;
480
481 /**
482 * Just like @touch.fit but without clamping x,y to the bounds of the
483 * target.
484 * @detail (target?, ax?, ay?)
485 */
486 αreframe(): void;
487 αreframe(start: Length, end: Length, snap?: number): void;
488 αreframe(context: Element | string, snap?: number): void;
489 αreframe(context: Element | string, start: Length, end: Length, snap?: number): void;
490
491 /**
492 * Allow pinning the touch to a certain point in an element, so that
493 * all future x,y values are relative to this pinned point.
494 * @detail (target?, ax?, ay?)
495 */
496 αpin(): void;
497 αpin(target: ModifierElementTarget): void;
498 αpin(anchorX: number, anchorY?: number): void;
499 αpin(target: ModifierElementTarget, anchorX?: number, anchorY?: number): void;
500
501 /**
502 * Round the x,y coordinates with an optional accuracy
503 * @detail (to = 1)
504 */
505 αround(nearest?: number): void;
506
507 /**
508 * Add an html class to target for at least 250ms
509 * If the callback returns a promise, the class
510 * will not be removed until said promise has resolved
511 * @param name the class to add
512 * @param target the element on which to add the class. Defaults to the element itself
513 * @detail (name,target?)
514 * */
515 αflag(name: string, target?: FlagTarget): void;
516
517 /**
518 * Add an html class to target for at least 250ms
519 * If the callback returns a promise, the class
520 * will not be removed until said promise has resolved
521 * @param target the element on which to add the class. Defaults to the element itself
522 * @deprecated
523 **/
524 αflagΞname(target?: FlagTarget): void;
525
526 /**
527 * Only trigger handler if event.target matches selector
528 * @detail (selector)
529 * */
530 αsel(selector: string): boolean;
531
532 /**
533 Tells the browser that the default action should not be taken. The event will still continue to propagate up the tree. See Event.preventDefault()
534 @see https://imba.io/events/event-modifiers#core-prevent
535 */
536 αprevent(): void;
537 /**
538 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()
539 */
540 αstop(): void;
541
542 /**
543 Prevents default action & stops event from bubbling.
544 */
545 αtrap(): void;
546
547 /**
548 * 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.
549 * @summary Only trigger handler if event.target is the element itself
550 */
551 αself(): boolean;
552
553 /**
554 * @summary Don't trigger imba.commit from this event handler
555 */
556 αsilent(): void;
557
558 /**
559 * @summary Suppress pointer events on all other elements
560 */
561 αlock(): void;
562
563 /**
564 * Only trigger condition is truthy
565 * @detail (condition)
566 * */
567 αif(condition: unknown): boolean;
568
569 }
570
571 type IntersectRoot = Element | Document;
572
573 type IntersectOptions = {
574 rootMargin?: string;
575 root?: IntersectRoot;
576 thresholds?: number[];
577 }
578
579 /**
580 [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.
581
582 #### Syntax
583
584 ```imba
585 # Will only trigger when intersection ratio increases
586 <div @intersect.in=handler>
587 # Will only trigger when element is more than 50% visible
588 <div @intersect(0.5).in=handler>
589 ```
590
591 #### Parameters
592
593 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).
594
595 ```imba
596 <div @intersect=handler> # default options
597 <div @intersect(root: frame, rootMargin: '20px')=handler>
598 <div @intersect(threshold: [0,0.5,1])=handler>
599 ```
600
601 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:
602 ```imba
603 # n 0-1 adds single threshold at n visibility
604 <div @intersect(0)=handler> # {threshold: 0}
605 <div @intersect(0.5)=handler> # {threshold: 0.5}
606 <div @intersect(1)=handler> # {threshold: 1.0}
607 ```
608 Any number above 1 will add n thresholds, spread evenly:
609 ```imba
610 <div @intersect(2)=handler> # {threshold: [0,1]}
611 <div @intersect(3)=handler> # {threshold: [0,0.5,1]}
612 <div @intersect(5)=handler> # {threshold: [0,0.25,0.5,0.75,1]}
613 # ... and so forth
614 ```
615 An element will map to the [root](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root) option:
616 ```imba
617 <div @intersect(frame)=handler> # {root: frame}
618 <div @intersect(frame,3)=handler> # {root: frame, threshold: [0,0.5,1]}
619 ```
620 A string will map to the [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin) option:
621 ```imba
622 <div @intersect("20px 10px")=handler> # {rootMargin: "20px 10px"}
623 ```
624 * @custom
625 */
626 class IntersectEvent extends Event {
627 /**
628 The `out` modifier stops the handler unless intersectionRatio has *increased*.
629
630 #### Syntax
631 ```imba
632 # Will only trigger when intersection ratio increases
633 <div @intersect.in=handler>
634 # Will only trigger when element is more than 50% visible
635 <div @intersect(0.5).in=handler>
636 ```
637 @summary Stop handling unless intersectionRatio has increased.
638 */
639 αin(): boolean;
640
641 /**
642 *
643 The `out` modifier stops the handler unless intersectionRatio has *decreased*.
644
645 #### Syntax
646 ```imba
647 # Will only trigger when element starts intersecting
648 <div @intersect.out=handler>
649 # Will trigger whenever any part of the div is hidden
650 <div @intersect(1).out=handler>
651 ```
652 @summary Stop handling unless intersectionRatio has decreased.
653 */
654 αout(): boolean;
655
656 /**
657 The css modifier sets a css variable --ratio on the event target with the current ratio.
658 @summary Set css variable `--ratio` to the intersectionRatio.
659 */
660 αcss(): void;
661
662 /**
663 * Will add a class to the DOM element when intersecting
664 * @param name The class-name to add
665 */
666 αflag(name: string): void;
667
668 /**
669 * Configuring
670 * @param root reference to the parent
671 * @param thresholds 0-1 for a single threshold, 2+ for n slices
672
673 */
674 αoptions(root?: IntersectRoot, thresholds?: number): void;
675
676 αoptions(thresholds?: number): void;
677 αoptions(rootMargin: string, thresholds?: number): void;
678 αoptions(rootMargin: string, thresholds?: number): void;
679 αoptions(options: IntersectOptions): void;
680
681 /**
682 * The raw IntersectionObserverEntry
683 *
684 */
685 entry: IntersectionObserverEntry;
686 /**
687 * Ratio of the intersectionRect to the boundingClientRect
688 *
689 */
690 ratio: number;
691 /**
692 * Difference in ratio since previous event
693 *
694 */
695 delta: number;
696 }
697
698 class HotkeyEvent extends Event {
699
700 /**
701 *
702 * @param pattern string following pattern from mousetrap
703 * @see https://craig.is/killing/mice
704 */
705 αoptions(pattern:string): void;
706
707 /**
708 * Also trigger when input,textarea or a contenteditable is focused
709 * @deprecated Use `force` instead
710 */
711 αcapture(): void;
712
713 /**
714 * Trigger even if outside of the originating hotkey group
715 */
716 αglobal(): void;
717
718 /**
719 * Trigger only if KeyboardEvent originates from this element or a child.
720 */
721 αlocal(): void;
722
723 /**
724 * Allow subsequent hotkey handlers for the same combo
725 * and don't automatically prevent default behaviour of originating
726 * keyboard event
727 */
728 αpassive(): void;
729
730 /**
731 * Also trigger when input,textarea or a contenteditable is focused
732 */
733 αforce(): void;
734
735 /**
736 * Allow the handler to trigger multiple times while user
737 * keeps pressing the key combination.
738 */
739 αrepeat(): void;
740
741 /**
742 * The KeyboardEvent responsible for this HotkeyEvent
743 *
744 */
745 readonly originalEvent: KeyboardEvent;
746
747 /**
748 * The combo for the event
749 *
750 */
751 readonly combo: string;
752 }
753
754 /**
755 * 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.
756 * @custom
757 */
758 class ResizeEvent extends UIEvent {
759 /** Width of the resized element */
760 readonly width: number;
761 /** Height of the resized element */
762 readonly height: number;
763
764 /** contentRect from the ResizeObserverEntry */
765 readonly rect: DOMRectReadOnly;
766 /** the raw ResizeObserverEntry */
767 readonly entry: ResizeObserverEntry;
768
769 /**
770 The css modifier sets css variables (or units) to the width/height
771 of the resized element
772 @summary Set css variables for width / height of resized element
773 */
774 αcss(wunit?:string, hunit?:string, selector?: FlagTarget): void;
775 }
776
777 class SelectionEvent extends Event {
778 detail: {
779 start: number;
780 end: number;
781 }
782 }
783}
784
785interface GlobalEventHandlersEventMap {
786 "touch": imba.Touch;
787 "intersect": imba.IntersectEvent;
788 "selection": imba.SelectionEvent;
789 "hotkey": imba.HotkeyEvent;
790 "resize": imba.ResizeEvent;
791 "__unknown": CustomEvent;
792}
793
794interface HTMLElementEventMap {
795 "resize": imba.ResizeEvent;
796}
797
798interface ImbaEvents {
799 /**
800 * The loading of a resource has been aborted.
801 *
802 */
803 abort: Event;
804 animationcancel: AnimationEvent;
805 /**
806 * A CSS animation has completed.
807 *
808 */
809 animationend: AnimationEvent;
810 /**
811 * A CSS animation is repeated.
812 *
813 */
814 animationiteration: AnimationEvent;
815 /**
816 * A CSS animation has started.
817 *
818 */
819 animationstart: AnimationEvent;
820
821 auxclick: MouseEvent;
822 /**
823 * An element has lost focus (does not bubble).
824 *
825 */
826 blur: FocusEvent;
827
828 cancel: Event;
829 /**
830 * 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.
831 *
832 */
833 canplay: Event;
834 /**
835 * The user agent can play the media up to its end without having to stop for further buffering of content.
836 *
837 */
838 canplaythrough: Event;
839 /**
840 * The change event is fired for `<input>`, `<select>`, and `<textarea>` elements when a change to the element's value is committed by the user.
841 *
842 */
843 change: Event;
844 /**
845 * A pointing device button has been pressed and released on an element.
846 *
847 */
848 click: MouseEvent;
849 close: Event;
850 contextmenu: MouseEvent;
851 cuechange: Event;
852 dblclick: MouseEvent;
853
854 drag: DragEvent;
855
856 dragend: DragEvent;
857
858 dragenter: DragEvent;
859
860 dragleave: DragEvent;
861
862 dragover: DragEvent;
863
864 dragstart: DragEvent;
865
866 /**
867 * @summaryz Fires when an element or text selection is dropped on a valid drop target.
868 */
869 drop: DragEvent;
870 durationchange: Event;
871 emptied: Event;
872 ended: Event;
873 error: ErrorEvent;
874 focus: FocusEvent;
875 focusin: FocusEvent;
876 focusout: FocusEvent;
877 /**
878 * @custom
879 * @summary Fired when the supplied keycombo is pressed anywhere in the document.
880 * @detail (combo)
881 */
882 hotkey: imba.HotkeyEvent;
883 input: Event;
884 invalid: Event;
885 /**
886 * @custom
887 * @summary Fired when the element appears in the viewport (or another element).
888 */
889 intersect: imba.IntersectEvent;
890 keydown: KeyboardEvent;
891 keypress: KeyboardEvent;
892 keyup: KeyboardEvent;
893 load: Event;
894 loadeddata: Event;
895 loadedmetadata: Event;
896 loadstart: Event;
897 mousedown: MouseEvent;
898 mouseenter: MouseEvent;
899 mouseleave: MouseEvent;
900 mousemove: MouseEvent;
901 mouseout: MouseEvent;
902 mouseover: MouseEvent;
903 mouseup: MouseEvent;
904 pause: Event;
905 play: Event;
906 playing: Event;
907
908 /**
909 * @summary A browser fires this event if it concludes the pointer will no longer be able to generate events (for example the related device is deactivated).
910 */
911 pointercancel: PointerEvent;
912 /**
913 * @summary Fired when a pointer becomes active buttons state.
914 */
915 pointerdown: PointerEvent;
916 /**
917 * @summary Fired when a pointer is moved into the hit test boundaries of an element or one of its descendants, including as a result of a pointerdown event from a device that does not support hover (see pointerdown).
918 */
919 pointerenter: PointerEvent;
920 /**
921 * @summary Fired when a pointer is moved out of the hit test boundaries of an element. For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer.
922 */
923 pointerleave: PointerEvent;
924 /**
925 * @summary Fired when a pointer changes coordinates. This event is also used if the change in pointer state can not be reported by other events.
926 */
927 pointermove: PointerEvent;
928
929 /**
930 * @summary Fired for several reasons including: pointer is moved out of the hit test boundaries of an element; firing the pointerup event for a device that does not support hover (see pointerup); after firing the pointercancel event (see pointercancel); when a pen stylus leaves the hover range detectable by the digitizer.
931 */
932 pointerout: PointerEvent;
933
934 /**
935 * @summary Fired when a pointer is moved into an element's hit test boundaries.
936 */
937 pointerover: PointerEvent;
938 /**
939 * @summary Fired when a pointer is no longer active buttons state.
940 */
941 pointerup: PointerEvent;
942
943 /**
944 * @summary Fired when an element receives pointer capture.
945 */
946 gotpointercapture: PointerEvent;
947
948 /**
949 * @summary Fired after pointer capture is released for a pointer.
950 */
951 lostpointercapture: PointerEvent;
952
953 progress: ProgressEvent;
954 ratechange: Event;
955 reset: Event;
956 /**
957 * @custom
958 * @summary Fired when element is resized.
959 */
960 resize: imba.ResizeEvent;
961 scroll: Event;
962 securitypolicyviolation: SecurityPolicyViolationEvent;
963 seeked: Event;
964 seeking: Event;
965 select: Event;
966 selectionchange: Event;
967 selectstart: Event;
968 stalled: Event;
969 submit: Event;
970 suspend: Event;
971 timeupdate: Event;
972 toggle: Event;
973 /**
974 * @custom
975 * @summary Normalized handler for pointerdown->move->up with powerful custom modifiers.
976 */
977 touch: imba.Touch;
978 touchcancel: TouchEvent;
979 touchend: TouchEvent;
980 touchmove: TouchEvent;
981 touchstart: TouchEvent;
982 transitioncancel: TransitionEvent;
983 transitionend: TransitionEvent;
984 transitionrun: TransitionEvent;
985 transitionstart: TransitionEvent;
986 volumechange: Event;
987 waiting: Event;
988 wheel: WheelEvent;
989 [event: string]: CustomEvent;
990}
\No newline at end of file