diff --git a/Tool/animate.js b/Tool/animate.js new file mode 100644 index 0000000..27a7f95 --- /dev/null +++ b/Tool/animate.js @@ -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); // 清洗动画 + }); +} diff --git a/Tool/number.js b/Tool/number.js new file mode 100644 index 0000000..d3c181c --- /dev/null +++ b/Tool/number.js @@ -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)); +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..dfbb88e --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +export { animate } from './Tool/animate.js'; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..af78296 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "ddmt-tool", + "version": "1.0.2", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ddmt-tool", + "version": "1.0.2", + "license": "ISC", + "dependencies": { + "ddmt-tool": "file:" + } + }, + "node_modules/ddmt-tool": { + "resolved": "", + "link": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..30cf38e --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "ddmt-tool", + "version": "1.0.2", + "description": "ddmt-tool", + "main": "index.js", + "type": "module", + "scripts": { + "dev": "node index.js" + }, + "keywords": [ + "ddmt", + "tool" + ], + "author": "ddmt", + "license": "ISC", + "dependencies": { + "ddmt-tool": "file:" + } +}