This commit is contained in:
2024-09-29 16:57:15 +08:00
parent 5d4723a005
commit c1cc5b2c4e
5 changed files with 73 additions and 0 deletions

11
Tool/animate.js Normal file
View File

@@ -0,0 +1,11 @@
/**
* 动画函数
* @param {HTMLElement} event
* @param {string} classname
*/
export function animate(event, classname) {
event.classList.add(classname);
event.addEventListener('animationend', (event) => {
event.classList.remove(classname); // 清洗动画
});
}

22
Tool/number.js Normal file
View File

@@ -0,0 +1,22 @@
//生成从minNum到maxNum的随机数
export function randomNum (minNum, maxNum) {
switch (arguments.length) {
case 1:
return parseInt(Math.random() * minNum + 1, 10);
case 2:
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
default:
return 0;
}
}
/*
* 数组循环函数
* @param {Array} arr
* @param {number} index
*/
export function nextArray(arr, index) {
index--;
return arr.slice(index + 1, arr.length).concat(arr.slice(0, index + 1));
}