Commit 971bb696 authored by 李纪文's avatar 李纪文

feat: 组态自动缩放问题修改

parent 472ace35
...@@ -623,6 +623,7 @@ const ConfigurationView = (props) => { ...@@ -623,6 +623,7 @@ const ConfigurationView = (props) => {
return () => { return () => {
isClose = true; isClose = true;
if (myDiagram) { if (myDiagram) {
myDiagram.removeDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.div = null; myDiagram.div = null;
myDiagram = null; myDiagram = null;
} }
...@@ -1112,6 +1113,12 @@ const ConfigurationView = (props) => { ...@@ -1112,6 +1113,12 @@ const ConfigurationView = (props) => {
setIsHIModalVisible(true); setIsHIModalVisible(true);
}; };
// 监听画布zoom变化
const viewportBoundsChang = () => {
myDiagram.contentAlignment = go.Spot.Default;
myDiagram.contentAlignment = go.Spot.Center;
};
/** **********************************画布渲染************************************ */ /** **********************************画布渲染************************************ */
const diagramRender = (jsonStr, chartInfo) => { const diagramRender = (jsonStr, chartInfo) => {
myDiagram = goJS( myDiagram = goJS(
...@@ -2583,6 +2590,8 @@ const ConfigurationView = (props) => { ...@@ -2583,6 +2590,8 @@ const ConfigurationView = (props) => {
if (item.controlType === '开关展示') item.switch = '是'; if (item.controlType === '开关展示') item.switch = '是';
if (item.category === 'valCase') item.shType = '值显示'; if (item.category === 'valCase') item.shType = '值显示';
}); });
// 监听画布变化
myDiagram.addDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.model = go.Model.fromJson(json); myDiagram.model = go.Model.fromJson(json);
}; };
......
...@@ -915,6 +915,7 @@ const ConfigurationView = (props) => { ...@@ -915,6 +915,7 @@ const ConfigurationView = (props) => {
mqttView = null; mqttView = null;
if (myDiagram) { if (myDiagram) {
myDiagram.removeDiagramListener('InitialAnimationStarting', animationStarting); myDiagram.removeDiagramListener('InitialAnimationStarting', animationStarting);
myDiagram.removeDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.div = null; myDiagram.div = null;
myDiagram = null; myDiagram = null;
setIsDiagram(null); setIsDiagram(null);
...@@ -1758,6 +1759,12 @@ const ConfigurationView = (props) => { ...@@ -1758,6 +1759,12 @@ const ConfigurationView = (props) => {
if (entryAnim === 'opacity') animations.add(e.diagram, 'opacity', 0, 1); if (entryAnim === 'opacity') animations.add(e.diagram, 'opacity', 0, 1);
}; };
// 监听画布zoom变化
const viewportBoundsChang = () => {
myDiagram.contentAlignment = go.Spot.Default;
myDiagram.contentAlignment = go.Spot.Center;
};
/** **********************************画布渲染************************************ */ /** **********************************画布渲染************************************ */
const diagramRender = (jsonStr, chartInfo) => { const diagramRender = (jsonStr, chartInfo) => {
myDiagram = goJS( myDiagram = goJS(
...@@ -3337,6 +3344,8 @@ const ConfigurationView = (props) => { ...@@ -3337,6 +3344,8 @@ const ConfigurationView = (props) => {
} }
// 动画监听 // 动画监听
myDiagram.addDiagramListener('InitialAnimationStarting', animationStarting); myDiagram.addDiagramListener('InitialAnimationStarting', animationStarting);
// 监听画布变化
myDiagram.addDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.model = go.Model.fromJson(json); myDiagram.model = go.Model.fromJson(json);
getDataModel(); getDataModel();
setIsDiagram(myDiagram); setIsDiagram(myDiagram);
......
...@@ -884,6 +884,7 @@ const ConfigurationView = (props) => { ...@@ -884,6 +884,7 @@ const ConfigurationView = (props) => {
mqttView && mqttView.disSaveWaconnect(); mqttView && mqttView.disSaveWaconnect();
mqttView = null; mqttView = null;
if (myDiagram) { if (myDiagram) {
myDiagram.removeDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.div = null; myDiagram.div = null;
myDiagram = null; myDiagram = null;
setIsDiagram(null); setIsDiagram(null);
...@@ -1687,6 +1688,12 @@ const ConfigurationView = (props) => { ...@@ -1687,6 +1688,12 @@ const ConfigurationView = (props) => {
return modalComponent && nodeData ? modalComponent() : null; return modalComponent && nodeData ? modalComponent() : null;
}; };
// 监听画布zoom变化
const viewportBoundsChang = () => {
myDiagram.contentAlignment = go.Spot.Default;
myDiagram.contentAlignment = go.Spot.Center;
};
/** **********************************画布渲染************************************ */ /** **********************************画布渲染************************************ */
const diagramRender = (jsonStr, chartInfo) => { const diagramRender = (jsonStr, chartInfo) => {
myDiagram = goJS( myDiagram = goJS(
...@@ -3244,6 +3251,8 @@ const ConfigurationView = (props) => { ...@@ -3244,6 +3251,8 @@ const ConfigurationView = (props) => {
if (item.controlType === '开关展示') item.switch = '是'; if (item.controlType === '开关展示') item.switch = '是';
if (item.category === 'valCase') item.shType = '值显示'; if (item.category === 'valCase') item.shType = '值显示';
}); });
// 监听画布变化
myDiagram.addDiagramListener('ViewportBoundsChanged', viewportBoundsChang);
myDiagram.model = go.Model.fromJson(json); myDiagram.model = go.Model.fromJson(json);
getDataModel(); getDataModel();
setIsDiagram(myDiagram); setIsDiagram(myDiagram);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment