update 0.8.2

This commit is contained in:
hufeixiong
2021-08-16 11:35:04 +08:00
parent 6e409dca10
commit 8d23f9477c
7 changed files with 50 additions and 14 deletions

View File

@@ -1,5 +1,11 @@
## changelog ## changelog
## 0.8.2
增加左侧面板配置。
修复timeline闪烁问题。
## 0.8.1 ## 0.8.1
新增动画组件timeline。可以更好预览所有动画。 新增动画组件timeline。可以更好预览所有动画。

View File

@@ -4,6 +4,12 @@ order: 1
--- ---
## changelog ## changelog
## 0.8.2
增加左侧面板配置。
修复timeline闪烁问题。
## 0.8.1 ## 0.8.1
新增动画组件timeline。可以更好预览所有动画。 新增动画组件timeline。可以更好预览所有动画。

View File

@@ -126,9 +126,8 @@ let isOmit = false;
function AnimateControl(props: AnimateControlProps) { function AnimateControl(props: AnimateControlProps) {
const store = props.config.getStore(); const store = props.config.getStore();
const animate = useMemo(() => { const animate = useMemo(() => {
if (isOmit) { if (isOmit || props.config.waitAnimate) {
return lastAnimate; return lastAnimate;
} }
lastAnimate = props.current.animate; lastAnimate = props.current.animate;
@@ -305,24 +304,27 @@ function AnimateControl(props: AnimateControlProps) {
onClick={() => { onClick={() => {
if (!isOmit) { if (!isOmit) {
isOmit = true; isOmit = true;
props.config.waitAnimate = true;
const cacheProps = animate; const cacheProps = animate;
const data: IStoreData = store.getData(); const data: IStoreData = deepCopy(store.getData());
data.block.forEach((v) => { data.block.forEach((v) => {
if (v.id === props.current.id) { if (v.id === props.current.id) {
v.animate = []; v.animate = [];
} }
}); });
store.emit(); store.setData(data);
store.forceUpdate();
setTimeout(() => { setTimeout(() => {
data.block.forEach((v) => { const clone: IStoreData = deepCopy(store.getData());
clone.block.forEach((v) => {
if (v.id === props.current.id) { if (v.id === props.current.id) {
v.animate = cacheProps; v.animate = cacheProps;
} }
}); });
store.emit();
store.forceUpdate();
isOmit = false; isOmit = false;
props.config.waitAnimate = false;
store.cleanLast();
store.setData(clone);
store.cleanLast();
}); });
} }
}} }}

View File

@@ -1,5 +1,5 @@
{ {
"version": "0.8.1", "version": "0.8.2",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/dooringx-lib.esm.js", "module": "dist/dooringx-lib.esm.js",

View File

@@ -2,11 +2,11 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-08-09 15:15:25 * @Date: 2021-08-09 15:15:25
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-08-11 17:03:54 * @LastEditTime: 2021-08-16 11:20:59
* @FilePath: \dooringx\packages\dooringx-lib\src\components\timeLine\timeline.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\components\timeLine\timeline.tsx
*/ */
import deepcopy from 'deepcopy'; import deepcopy from 'deepcopy';
import React, { CSSProperties, useState } from 'react'; import React, { CSSProperties, useMemo, useState } from 'react';
import { SortableContainer, SortableElement, SortableHandle, SortEnd } from 'react-sortable-hoc'; import { SortableContainer, SortableElement, SortableHandle, SortEnd } from 'react-sortable-hoc';
import UserConfig from '../../config'; import UserConfig from '../../config';
import { IBlockType, IStoreData } from '../../core/store/storetype'; import { IBlockType, IStoreData } from '../../core/store/storetype';
@@ -82,6 +82,8 @@ const SortableList = SortableContainer(
} }
); );
let cacheBlock: IBlockType[] = [];
export function TimeLine(props: TimeLineProps) { export function TimeLine(props: TimeLineProps) {
const store = props.config.getStore(); const store = props.config.getStore();
const data = store.getData().block; const data = store.getData().block;
@@ -122,6 +124,14 @@ export function TimeLine(props: TimeLineProps) {
</div> </div>
); );
const renderData = useMemo(() => {
if (props.config.waitAnimate) {
return cacheBlock;
}
cacheBlock = data;
return cacheBlock;
}, [data, props.config.waitAnimate]);
return ( return (
<div <div
className={props.classes} className={props.classes}
@@ -168,6 +178,7 @@ export function TimeLine(props: TimeLineProps) {
//缓存所有animate后执行 //缓存所有animate后执行
if (!WAIT) { if (!WAIT) {
WAIT = true; WAIT = true;
props.config.waitAnimate = true;
const cache = data.map((v) => { const cache = data.map((v) => {
return v.animate; return v.animate;
}); });
@@ -182,6 +193,7 @@ export function TimeLine(props: TimeLineProps) {
v.animate = cache[i]; v.animate = cache[i];
}); });
WAIT = false; WAIT = false;
props.config.waitAnimate = false;
store.setData(cloneData); store.setData(cloneData);
}); });
} }
@@ -256,7 +268,7 @@ export function TimeLine(props: TimeLineProps) {
}} }}
style={{ overflow: 'auto', height: `calc(100% - ${itemHeight}px)` }} style={{ overflow: 'auto', height: `calc(100% - ${itemHeight}px)` }}
> >
{data.map((v) => { {renderData.map((v) => {
return ( return (
<div <div
key={v.id} key={v.id}

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-02-25 21:16:58 * @Date: 2021-02-25 21:16:58
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-08-11 16:16:09 * @LastEditTime: 2021-08-16 10:17:55
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx * @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
*/ */
import React from 'react'; import React from 'react';
@@ -345,6 +345,7 @@ export class UserConfig {
public collapsed = false; public collapsed = false;
public ticker = true; public ticker = true;
public timeline = false; public timeline = false;
public waitAnimate = false;
public wrapperMoveState = wrapperMoveState; public wrapperMoveState = wrapperMoveState;
public iframeWrapperMoveState = iframeWrapperMoveState; public iframeWrapperMoveState = iframeWrapperMoveState;
public refreshIframe = () => {}; public refreshIframe = () => {};

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 04:29:09 * @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-13 14:58:30 * @LastEditTime: 2021-08-16 11:18:41
* @FilePath: \dooringx\packages\dooringx-lib\src\core\store\index.ts * @FilePath: \dooringx\packages\dooringx-lib\src\core\store\index.ts
*/ */
import { IStoreData } from './storetype'; import { IStoreData } from './storetype';
@@ -130,6 +130,15 @@ class Store {
this.emit(); this.emit();
} }
cleanLast() {
if (this.current <= 1) {
return;
}
const removeIndex = this.current - 1;
this.storeDataList.splice(removeIndex, 1);
this.current = this.current - 1;
}
emit() { emit() {
this.listeners.forEach((fn) => { this.listeners.forEach((fn) => {
fn(this.getData()); fn(this.getData());