修改代码

This commit is contained in:
ival 2021-04-04 02:16:22 +08:00
parent f16c7e0b11
commit 3026eed365
5 changed files with 33 additions and 19 deletions

View File

@ -45,7 +45,8 @@ class Animate {
const mapView = traverse(shape, {});
if(shape && frameList) {
const size = frameList.length;
const frame = frameList[this.count%size];
const index = this.count%size;
const frame = frameList[index];
Object.keys(frame).forEach(name => {
const view = mapView[name];
const model = frame[name];

View File

@ -1,4 +1,5 @@
const defStatus = 'defStatus';
import * as utils from '../utils/utils';
class TemplateParser {
constructor() {
}
@ -17,10 +18,10 @@ class TemplateParser {
parseShape(list=[], map={}) {
list.forEach(el => {
const shapeMap = map[el.name] = {};
shapeMap[defStatus] = { status: defStatus, style: el.style, shape: el.shape };
const mapShape = map[el.name] = {};
mapShape[utils.defStatus] = { status: utils.defStatus, style: el.style, shape: el.shape };
(el.stateList||[]).forEach(it => {
shapeMap[it.status] = it;
mapShape[it.status] = it;
})
})
return map;

View File

@ -1,3 +1,4 @@
import * as utils from './utils/utils';
export default class StateHandle {
constructor(map) {
@ -9,6 +10,16 @@ export default class StateHandle {
const template = mapTemplate[state.type];
const templateState = template.mapState[state.status];
if (templateState.needDefault) {
templateState.frameList.unshift(
Object.entries(template.mapShape).map(el => {
return { name: el[0], ...el[1][utils.defStatus]};
})
);
}
console.log(Object.entries(template.mapShape))
return {
...state,
...templateState,

View File

@ -1,12 +1,13 @@
import BoundingRect from 'zrender/src/core/BoundingRect';
import * as matrix from 'zrender/src/core/matrix';
var base = 0;
// 默认状态标识
export const defStatus = 'default';
// 获取一个UID
export function getUID(type) {
return [(type || ''), base++, Math.random().toFixed(5)].join('_');
}
export const getUID =(function(base=0) {
return function(type) { return [(type || ''), base++, Math.random().toFixed(5)].join('_');}
})();
// 克隆一个对象
export function deepClone(obj) {

View File

@ -286,17 +286,17 @@ export default {
scale: [1, 1],
position: [200, 0],
rotation: 0,
// composeCode: '1000'
composeCode: '1000'
},
// {
// code: '1000',
// type: 'Device',
// scale: [1, 1],
// position: [0, 0],
// rotation: 0,
// elementCodes: ['100', '101'],
// composeCode: ''
// }
{
code: '1000',
type: 'Device',
scale: [1, 1],
position: [0, 0],
rotation: 0,
elementCodes: ['100', '101'],
composeCode: ''
}
]
}, {
panEnable: true,