mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-03 15:55:39 +00:00
Document optional delay parameter for addClass, removeClass, remove (#820)
thank you!
This commit is contained in:
parent
c49ce64d2d
commit
bda02d0d66
9
src/htmx.d.ts
vendored
9
src/htmx.d.ts
vendored
@ -7,8 +7,9 @@
|
|||||||
*
|
*
|
||||||
* @param elt the element to add the class to
|
* @param elt the element to add the class to
|
||||||
* @param clazz the class to add
|
* @param clazz the class to add
|
||||||
|
* @param delay the delay (in milliseconds before class is added)
|
||||||
*/
|
*/
|
||||||
export function addClass(elt: Element, clazz: string): void;
|
export function addClass(elt: Element, clazz: string, delay?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issues an htmx-style AJAX request
|
* Issues an htmx-style AJAX request
|
||||||
@ -219,8 +220,9 @@ export function process(element: Element): void;
|
|||||||
* https://htmx.org/api/#remove
|
* https://htmx.org/api/#remove
|
||||||
*
|
*
|
||||||
* @param elt element to remove
|
* @param elt element to remove
|
||||||
|
* @param delay the delay (in milliseconds before element is removed)
|
||||||
*/
|
*/
|
||||||
export function remove(elt: Element): void;
|
export function remove(elt: Element, delay?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a class from the given element
|
* Removes a class from the given element
|
||||||
@ -229,8 +231,9 @@ export function remove(elt: Element): void;
|
|||||||
*
|
*
|
||||||
* @param elt element to remove the class from
|
* @param elt element to remove the class from
|
||||||
* @param clazz the class to remove
|
* @param clazz the class to remove
|
||||||
|
* @param delay the delay (in milliseconds before class is removed)
|
||||||
*/
|
*/
|
||||||
export function removeClass(elt: Element, clazz: string): void;
|
export function removeClass(elt: Element, clazz: string, delay?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given extension from htmx
|
* Removes the given extension from htmx
|
||||||
|
26
www/api.md
26
www/api.md
@ -19,11 +19,20 @@ This method adds a class to the given element.
|
|||||||
* `elt` - the element to add the class to
|
* `elt` - the element to add the class to
|
||||||
* `class` - the class to add
|
* `class` - the class to add
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
* `elt` - the element to add the class to
|
||||||
|
* `class` - the class to add
|
||||||
|
* `delay` - delay (in milliseconds ) before class is added
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// add the class 'myClass' to the element with the id 'demo'
|
// add the class 'myClass' to the element with the id 'demo'
|
||||||
htmx.addClass(htmx.find('#demo'), 'myClass');
|
htmx.addClass(htmx.find('#demo'), 'myClass');
|
||||||
|
|
||||||
|
// add the class 'myClass' to the element with the id 'demo' after 1 second
|
||||||
|
htmx.addClass(htmx.find('#demo'), 'myClass', 1000);
|
||||||
```
|
```
|
||||||
|
|
||||||
### <a name="ajax"></a> Method - [`htmx.ajax()`](#ajax)
|
### <a name="ajax"></a> Method - [`htmx.ajax()`](#ajax)
|
||||||
@ -363,11 +372,19 @@ Removes an element from the DOM
|
|||||||
|
|
||||||
* `elt` - element to remove
|
* `elt` - element to remove
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
* `elt` - element to remove
|
||||||
|
* `delay` - delay (in milliseconds ) before element is removed
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// removes my-div from the DOM
|
// removes my-div from the DOM
|
||||||
htmx.remove(htmx.find("#my-div"));
|
htmx.remove(htmx.find("#my-div"));
|
||||||
|
|
||||||
|
// removes my-div from the DOM after a delay of 2 seconds
|
||||||
|
htmx.remove(htmx.find("#my-div"), 2000);
|
||||||
```
|
```
|
||||||
|
|
||||||
### <a name="removeClass"></a> Method - [`htmx.removeClass()`](#removeClass)
|
### <a name="removeClass"></a> Method - [`htmx.removeClass()`](#removeClass)
|
||||||
@ -379,11 +396,20 @@ Removes a class from the given element
|
|||||||
* `elt` - element to remove the class from
|
* `elt` - element to remove the class from
|
||||||
* `class` - the class to remove
|
* `class` - the class to remove
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
* `elt` - element to remove the class from
|
||||||
|
* `class` - the class to remove
|
||||||
|
* `delay` - delay (in milliseconds ) before class is removed
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// removes .myClass from my-div
|
// removes .myClass from my-div
|
||||||
htmx.removeClass(htmx.find("#my-div"), "myClass");
|
htmx.removeClass(htmx.find("#my-div"), "myClass");
|
||||||
|
|
||||||
|
// removes .myClass from my-div after 6 seconds
|
||||||
|
htmx.removeClass(htmx.find("#my-div"), "myClass", 6000);
|
||||||
```
|
```
|
||||||
|
|
||||||
### <a name="removeExtension"></a> Method - [`htmx.removeExtension()`](#removeExtension)
|
### <a name="removeExtension"></a> Method - [`htmx.removeExtension()`](#removeExtension)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user