Skip to content

Commit

Permalink
放大的问题,之前弄复杂了,现在改成直接了当的,不管是刚进入页面还是改变窗口大小,都用窗口大小和canvas高度计算比例然后缩放
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuai1001 committed Aug 7, 2018
1 parent 71d664d commit f0316ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/components/RunMap4.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export default {
},
},
mounted() {
this.handleClientHeight(document.documentElement.clientHeight);
this.ctx = document.getElementById("myCanvas").getContext("2d");
this.ctxBelt = document.getElementById("myCanvasBelt").getContext("2d");
Expand Down Expand Up @@ -1000,15 +1001,18 @@ export default {
},
setPageScale(val, baseline) {
let newPageScale = (val / baseline).toFixed(3) - 0.07 ;
if (this.transformBig && this.unitPageScale < newPageScale ) {
this.unitPageScale = newPageScale;
}
if (!this.transformBig && this.unitPageScale > newPageScale ) {
this.unitPageScale = newPageScale;
}
console.log(val, baseline)
let newPageScale = (val / baseline).toFixed(3) ;
// if (this.transformBig && this.unitPageScale < newPageScale ) {
// this.unitPageScale = newPageScale;
// }
// if (!this.transformBig && this.unitPageScale > newPageScale ) {
// this.unitPageScale = newPageScale;
// }
this.unitPageScale = newPageScale;
},
handleClientHeight(val) {
console.log("handleClientHeight")
// if (val < 700) {
// this.unitPageScale = (val / 700).toFixed(3);
// this.unitPageScaleTop = (val - 700) / 2;
Expand All @@ -1021,18 +1025,19 @@ export default {
// }
let newClientHeight = document.documentElement.clientHeight;
let baseline = 700;
if (newClientHeight > baseline) {
baseline = newClientHeight;
}
let baseline = 760;
// if (newClientHeight > baseline) {
// baseline = newClientHeight;
// }
if (val < baseline) {
this.setPageScale(val, baseline);
} else if (val >= baseline && val <= 1080) {
if (this.clientWidth >= 900) {
this.unitPageScale = 1;
// this.unitPageScale = 1;
}
this.setPageScale(val, 760);
} else {
this.setPageScale(val, 1080);
this.setPageScale(val, 760);
}
},
throttle(val, type = "width") {
Expand Down
Binary file not shown.

0 comments on commit f0316ff

Please sign in to comment.