utils jsdoc
This commit is contained in:
parent
fe23109834
commit
a63421b675
1 changed files with 28 additions and 0 deletions
28
utils.js
28
utils.js
|
@ -1,11 +1,24 @@
|
||||||
import { class_ } from "./main.js";
|
import { class_ } from "./main.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* async wait/pause function
|
||||||
|
*
|
||||||
|
* @param {number} ms
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export const wait = (ms) => {
|
export const wait = (ms) => {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
setTimeout(res, ms);
|
setTimeout(res, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fadeout an Element.
|
||||||
|
*
|
||||||
|
* @param {HTMLElement|class_} Selems Element ot fade
|
||||||
|
* @param {number} [ms] Duration in ms
|
||||||
|
* @param {boolean} [force]
|
||||||
|
*/
|
||||||
export const fadeout = async (Selems, ms = 200, force = false) => {
|
export const fadeout = async (Selems, ms = 200, force = false) => {
|
||||||
var oldTrans = [];
|
var oldTrans = [];
|
||||||
if (!Array.isArray(Selems)) Selems = [Selems];
|
if (!Array.isArray(Selems)) Selems = [Selems];
|
||||||
|
@ -29,6 +42,15 @@ export const fadeout = async (Selems, ms = 200, force = false) => {
|
||||||
elems[i].style.transition = oldTrans[i];
|
elems[i].style.transition = oldTrans[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fadein an Element.
|
||||||
|
*
|
||||||
|
* @param {HTMLElement|class_} Selems Element to fade
|
||||||
|
* @param {number} [ms] Duration in ms
|
||||||
|
* @param {boolean} [force]
|
||||||
|
* @param {string} [display] Set destroyed display style tag.
|
||||||
|
*/
|
||||||
export const fadein = async (Selems, ms = 200, force = false, display="") => {
|
export const fadein = async (Selems, ms = 200, force = false, display="") => {
|
||||||
var oldTrans = [];
|
var oldTrans = [];
|
||||||
if (!Array.isArray(Selems)) Selems = [Selems];
|
if (!Array.isArray(Selems)) Selems = [Selems];
|
||||||
|
@ -53,6 +75,12 @@ export const fadein = async (Selems, ms = 200, force = false, display="") => {
|
||||||
}
|
}
|
||||||
|
|
||||||
var bStack = [];
|
var bStack = [];
|
||||||
|
/**
|
||||||
|
* The callback will be triggered when the user intends to go back.
|
||||||
|
*
|
||||||
|
* @param {function} callback
|
||||||
|
* @returns {function} cancle callback
|
||||||
|
*/
|
||||||
export const subCancel = (callback) => {
|
export const subCancel = (callback) => {
|
||||||
bStack.push(callback);
|
bStack.push(callback);
|
||||||
return ()=>{
|
return ()=>{
|
||||||
|
|
Loading…
Reference in a new issue