diff --git a/Tool/animate.js b/Tool/animate.js index 4bbe964..3ab1f76 100644 --- a/Tool/animate.js +++ b/Tool/animate.js @@ -21,3 +21,21 @@ export function animateStart(HTMLElement, className, forceExecute=false) { event.target.classList.remove(className); // 清洗动画 }); } + +/** + * 设置CSS变量值 + * @param {string} varName + * @param {string} value + */ +export function setClassVar(varName, value) { + document.documentElement.style.setProperty(varName, value); +} + +/** + * 获取CSS变量值 + * @param {string} varName + * @returns + */ +export function getStyleVar(varName) { + return getComputedStyle(document.documentElement).getPropertyValue(varName); +} \ No newline at end of file diff --git a/index.js b/index.js index fb3dae4..0361536 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,8 @@ /* * @Author: ddmt - * @version: 1.0.6 + * @version: 1.0.8 * @Date: 2024-9-29 20:50:12 - * @LastEditTime: 2024-9-29 20:50:12 + * @LastEditTime: 2024-11-15 20:50:12 * @LastEditors: ddmt * @Description: ddmt-index file * @FilePath: /index.js diff --git a/package.json b/package.json index adba31d..e852354 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ddmt-tool", - "version": "0.0.2-beta.1", + "version": "0.0.3", "description": "A utility library that provides commonly used functions to simplify everyday development tasks. Whether it's string manipulation, array operations, or other frequent functionalities, `ddmt-tool` helps you work more efficiently.", "main": "index.js", "type": "module", diff --git a/types/index.d.ts b/types/index.d.ts index 2aa74aa..1cba973 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,8 +1,12 @@ declare module 'ddmt-tool' { + // Tool/animate.js export function animateStart(event: HTMLElement, className: string, forceExecute?: boolean): void; + export function setClassVar(varName: string, value: string): void; + export function getClassVar(varName: string): String; + // Tool/number.js export function randomNum(minNum: number): number; export function randomNum(minNum: number, maxNum: number): number; - export function nextArray(arr: any[], index: number): any[]; + } \ No newline at end of file