From 0e8baf35025fefae1d70f764e34982f1db16676a Mon Sep 17 00:00:00 2001 From: hufeixiong Date: Wed, 30 Mar 2022 18:03:07 +0800 Subject: [PATCH] update --- .../plugin/formComponents/animateControl.tsx | 68 ++++++++++++------- .../src/core/dynamicAnimate/index.ts | 50 ++++++++++++-- 2 files changed, 87 insertions(+), 31 deletions(-) diff --git a/packages/dooringx-example/src/plugin/formComponents/animateControl.tsx b/packages/dooringx-example/src/plugin/formComponents/animateControl.tsx index 0f69cf7..4828fd9 100644 --- a/packages/dooringx-example/src/plugin/formComponents/animateControl.tsx +++ b/packages/dooringx-example/src/plugin/formComponents/animateControl.tsx @@ -14,7 +14,7 @@ interface AnimateControlProps { config: UserConfig; } -//类型待修改 +// 左侧实际类名-显示名称 const animateCategory: Record = { '': '无', animate__bounce: 'bounce', @@ -141,11 +141,29 @@ function AnimateControl(props: AnimateControlProps) { return ( <> + + + + {animate.map((v, i) => { return (
- {v.isCustom &&
自定义
} - {!v.isCustom && ( + { <> 动画名称: @@ -304,7 +322,7 @@ function AnimateControl(props: AnimateControlProps) { - )} + }
); })} @@ -366,13 +384,6 @@ function AnimateControl(props: AnimateControlProps) { > 添加动画 - { + form.resetFields(); setCustomModal(false); }} >
- - - - - - - - - - + + + + + + {(fields, { add, remove }) => ( <> {fields.map(({ key, name, ...restField }) => ( - + - + - + - + + + + @@ -420,7 +436,7 @@ function AnimateControl(props: AnimateControlProps) { ))} diff --git a/packages/dooringx-lib/src/core/dynamicAnimate/index.ts b/packages/dooringx-lib/src/core/dynamicAnimate/index.ts index 7d464ec..e992e97 100644 --- a/packages/dooringx-lib/src/core/dynamicAnimate/index.ts +++ b/packages/dooringx-lib/src/core/dynamicAnimate/index.ts @@ -1,10 +1,26 @@ -// 批量情况 +export interface CustomAnimateObj { + displayName: string; + animateName: string; + keyframe: string; +} export class DynamicAnimate { + constructor(public customAnimateName: Array = []) {} + + getCustomAnimateName() { + return this.customAnimateName; + } getStyleSheets() { return document.styleSheets; } + /** + * + * 插入动画 + * @param {string} ruleText + * @param {string} keyframeName + * @memberof DynamicAnimate + */ inserKeyframeAnimate(ruleText: string, keyframeName: string) { const sheets = this.getStyleSheets(); if (sheets.length === 0) { @@ -33,10 +49,34 @@ export class DynamicAnimate { sheet.insertRule(ruleText, sheet.rules ? sheet.rules.length : sheet.cssRules.length); } - fromObjInsertKeyFrame(obj: Record) { - // name 唯一 - Object.keys(obj).forEach((v) => { - this.inserKeyframeAnimate(obj[v], v); + /** + * + * 配置时使用 + * @param {Array} [customAnimateName=[]] + * @memberof DynamicAnimate + */ + addCustomAnimate(customAnimateName: Array = []) { + this.customAnimateName = [...this.customAnimateName, ...customAnimateName]; + } + + /** + * + * 删除使用animateName 防止displayName重名 + * @param {string} animateName + * @memberof DynamicAnimate + */ + deleteCustomAnimate(animateName: string) { + this.customAnimateName = this.customAnimateName.filter((v) => v.animateName !== animateName); + } + + /** + * + * 从配置项插入动画 导入设置 + * @memberof DynamicAnimate + */ + fromArrInsertKeyFrame(customAnimateName: Array = this.customAnimateName) { + customAnimateName.forEach((v) => { + this.inserKeyframeAnimate(v.keyframe, v.animateName); }); } }