update
This commit is contained in:
@@ -14,7 +14,7 @@ interface AnimateControlProps {
|
|||||||
config: UserConfig;
|
config: UserConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
//类型待修改
|
// 左侧实际类名-显示名称
|
||||||
const animateCategory: Record<string, string> = {
|
const animateCategory: Record<string, string> = {
|
||||||
'': '无',
|
'': '无',
|
||||||
animate__bounce: 'bounce',
|
animate__bounce: 'bounce',
|
||||||
@@ -141,11 +141,29 @@ function AnimateControl(props: AnimateControlProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Space
|
||||||
|
style={{ display: 'flex', marginBottom: 8, justifyContent: 'space-around' }}
|
||||||
|
align="baseline"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setCustomModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
添加自定义动画
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setCustomModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
删除自定义动画
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
{animate.map((v, i) => {
|
{animate.map((v, i) => {
|
||||||
return (
|
return (
|
||||||
<div key={v.uid} style={{ borderBottom: '1px dotted #9e9e9e' }}>
|
<div key={v.uid} style={{ borderBottom: '1px dotted #9e9e9e' }}>
|
||||||
{v.isCustom && <div>自定义</div>}
|
{
|
||||||
{!v.isCustom && (
|
|
||||||
<>
|
<>
|
||||||
<Row style={{ padding: padding, alignItems: 'center' }}>
|
<Row style={{ padding: padding, alignItems: 'center' }}>
|
||||||
<Col span={5}>动画名称:</Col>
|
<Col span={5}>动画名称:</Col>
|
||||||
@@ -304,7 +322,7 @@ function AnimateControl(props: AnimateControlProps) {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
)}
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -366,13 +384,6 @@ function AnimateControl(props: AnimateControlProps) {
|
|||||||
>
|
>
|
||||||
添加动画
|
添加动画
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setCustomModal(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
添加自定义动画
|
|
||||||
</Button>
|
|
||||||
</Row>
|
</Row>
|
||||||
<Modal
|
<Modal
|
||||||
width={800}
|
width={800}
|
||||||
@@ -383,35 +394,40 @@ function AnimateControl(props: AnimateControlProps) {
|
|||||||
console.log('ok', form.getFieldsValue());
|
console.log('ok', form.getFieldsValue());
|
||||||
}}
|
}}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
|
form.resetFields();
|
||||||
setCustomModal(false);
|
setCustomModal(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form form={form}>
|
<Form form={form}>
|
||||||
<Col>
|
<Form.Item labelCol={{ span: 6 }} name="displayName" label="自定义动画显示名称">
|
||||||
<Form.Item name={'kkk'} label="解决">
|
<Input></Input>
|
||||||
<Select></Select>
|
</Form.Item>
|
||||||
</Form.Item>
|
<Form.Item
|
||||||
</Col>
|
initialValue={`dooringx_${Math.random().toString(36).slice(2)}`}
|
||||||
<Col>
|
labelCol={{ span: 6 }}
|
||||||
<Form.Item name={'dfd'} label="解决">
|
name="animateName"
|
||||||
<Select></Select>
|
label="自定义动画名称"
|
||||||
</Form.Item>
|
>
|
||||||
</Col>
|
<Input disabled></Input>
|
||||||
|
</Form.Item>
|
||||||
<Form.List name="users">
|
<Form.List name="users">
|
||||||
{(fields, { add, remove }) => (
|
{(fields, { add, remove }) => (
|
||||||
<>
|
<>
|
||||||
{fields.map(({ key, name, ...restField }) => (
|
{fields.map(({ key, name, ...restField }) => (
|
||||||
<Space key={key} style={{ display: 'flex', marginBottom: 8 }} align="baseline">
|
<Space key={key} style={{ display: 'flex', marginBottom: 8 }} align="baseline">
|
||||||
<Form.Item label="坐标" {...restField} name={[name, 'xx']}>
|
<Form.Item label="坐标x" {...restField} name={[name, 'xx']}>
|
||||||
<Input placeholder="First Name" />
|
<Input placeholder="First Name" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="坐标" {...restField} name={[name, 'cc']}>
|
<Form.Item label="坐标y" {...restField} name={[name, 'cc']}>
|
||||||
<Input placeholder="Last Name" />
|
<Input placeholder="Last Name" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="坐标" {...restField} name={[name, '坐标']}>
|
<Form.Item label="旋转" {...restField} name={[name, '坐标']}>
|
||||||
<Input placeholder="First Name" />
|
<Input placeholder="First Name" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="坐标" {...restField} name={[name, '旋转']}>
|
<Form.Item label="缩放" {...restField} name={[name, '旋转']}>
|
||||||
|
<Input placeholder="Last Name" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="透明" {...restField} name={[name, '旋转']}>
|
||||||
<Input placeholder="Last Name" />
|
<Input placeholder="Last Name" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
@@ -420,7 +436,7 @@ function AnimateControl(props: AnimateControlProps) {
|
|||||||
))}
|
))}
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
|
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
|
||||||
Add field
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</>
|
</>
|
||||||
|
@@ -1,10 +1,26 @@
|
|||||||
// 批量情况
|
export interface CustomAnimateObj {
|
||||||
|
displayName: string;
|
||||||
|
animateName: string;
|
||||||
|
keyframe: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class DynamicAnimate {
|
export class DynamicAnimate {
|
||||||
|
constructor(public customAnimateName: Array<CustomAnimateObj> = []) {}
|
||||||
|
|
||||||
|
getCustomAnimateName() {
|
||||||
|
return this.customAnimateName;
|
||||||
|
}
|
||||||
getStyleSheets() {
|
getStyleSheets() {
|
||||||
return document.styleSheets;
|
return document.styleSheets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 插入动画
|
||||||
|
* @param {string} ruleText
|
||||||
|
* @param {string} keyframeName
|
||||||
|
* @memberof DynamicAnimate
|
||||||
|
*/
|
||||||
inserKeyframeAnimate(ruleText: string, keyframeName: string) {
|
inserKeyframeAnimate(ruleText: string, keyframeName: string) {
|
||||||
const sheets = this.getStyleSheets();
|
const sheets = this.getStyleSheets();
|
||||||
if (sheets.length === 0) {
|
if (sheets.length === 0) {
|
||||||
@@ -33,10 +49,34 @@ export class DynamicAnimate {
|
|||||||
sheet.insertRule(ruleText, sheet.rules ? sheet.rules.length : sheet.cssRules.length);
|
sheet.insertRule(ruleText, sheet.rules ? sheet.rules.length : sheet.cssRules.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
fromObjInsertKeyFrame(obj: Record<string, string>) {
|
/**
|
||||||
// name 唯一
|
*
|
||||||
Object.keys(obj).forEach((v) => {
|
* 配置时使用
|
||||||
this.inserKeyframeAnimate(obj[v], v);
|
* @param {Array<CustomAnimateObj>} [customAnimateName=[]]
|
||||||
|
* @memberof DynamicAnimate
|
||||||
|
*/
|
||||||
|
addCustomAnimate(customAnimateName: Array<CustomAnimateObj> = []) {
|
||||||
|
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<CustomAnimateObj> = this.customAnimateName) {
|
||||||
|
customAnimateName.forEach((v) => {
|
||||||
|
this.inserKeyframeAnimate(v.keyframe, v.animateName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user