修改代码
This commit is contained in:
parent
f16c7e0b11
commit
3026eed365
@ -45,7 +45,8 @@ class Animate {
|
|||||||
const mapView = traverse(shape, {});
|
const mapView = traverse(shape, {});
|
||||||
if(shape && frameList) {
|
if(shape && frameList) {
|
||||||
const size = frameList.length;
|
const size = frameList.length;
|
||||||
const frame = frameList[this.count%size];
|
const index = this.count%size;
|
||||||
|
const frame = frameList[index];
|
||||||
Object.keys(frame).forEach(name => {
|
Object.keys(frame).forEach(name => {
|
||||||
const view = mapView[name];
|
const view = mapView[name];
|
||||||
const model = frame[name];
|
const model = frame[name];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const defStatus = 'defStatus';
|
import * as utils from '../utils/utils';
|
||||||
|
|
||||||
class TemplateParser {
|
class TemplateParser {
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
@ -17,10 +18,10 @@ class TemplateParser {
|
|||||||
|
|
||||||
parseShape(list=[], map={}) {
|
parseShape(list=[], map={}) {
|
||||||
list.forEach(el => {
|
list.forEach(el => {
|
||||||
const shapeMap = map[el.name] = {};
|
const mapShape = map[el.name] = {};
|
||||||
shapeMap[defStatus] = { status: defStatus, style: el.style, shape: el.shape };
|
mapShape[utils.defStatus] = { status: utils.defStatus, style: el.style, shape: el.shape };
|
||||||
(el.stateList||[]).forEach(it => {
|
(el.stateList||[]).forEach(it => {
|
||||||
shapeMap[it.status] = it;
|
mapShape[it.status] = it;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return map;
|
return map;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import * as utils from './utils/utils';
|
||||||
|
|
||||||
export default class StateHandle {
|
export default class StateHandle {
|
||||||
constructor(map) {
|
constructor(map) {
|
||||||
@ -9,6 +10,16 @@ export default class StateHandle {
|
|||||||
const template = mapTemplate[state.type];
|
const template = mapTemplate[state.type];
|
||||||
const templateState = template.mapState[state.status];
|
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 {
|
return {
|
||||||
...state,
|
...state,
|
||||||
...templateState,
|
...templateState,
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import BoundingRect from 'zrender/src/core/BoundingRect';
|
import BoundingRect from 'zrender/src/core/BoundingRect';
|
||||||
import * as matrix from 'zrender/src/core/matrix';
|
import * as matrix from 'zrender/src/core/matrix';
|
||||||
|
|
||||||
var base = 0;
|
// 默认状态标识
|
||||||
|
export const defStatus = 'default';
|
||||||
|
|
||||||
// 获取一个UID
|
// 获取一个UID
|
||||||
export function getUID(type) {
|
export const getUID =(function(base=0) {
|
||||||
return [(type || ''), base++, Math.random().toFixed(5)].join('_');
|
return function(type) { return [(type || ''), base++, Math.random().toFixed(5)].join('_');}
|
||||||
}
|
})();
|
||||||
|
|
||||||
// 克隆一个对象
|
// 克隆一个对象
|
||||||
export function deepClone(obj) {
|
export function deepClone(obj) {
|
||||||
|
@ -286,17 +286,17 @@ export default {
|
|||||||
scale: [1, 1],
|
scale: [1, 1],
|
||||||
position: [200, 0],
|
position: [200, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
// composeCode: '1000'
|
composeCode: '1000'
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// code: '1000',
|
code: '1000',
|
||||||
// type: 'Device',
|
type: 'Device',
|
||||||
// scale: [1, 1],
|
scale: [1, 1],
|
||||||
// position: [0, 0],
|
position: [0, 0],
|
||||||
// rotation: 0,
|
rotation: 0,
|
||||||
// elementCodes: ['100', '101'],
|
elementCodes: ['100', '101'],
|
||||||
// composeCode: ''
|
composeCode: ''
|
||||||
// }
|
}
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
panEnable: true,
|
panEnable: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user