Commit 499f43f9 authored by 范雪寒's avatar 范雪寒

feat: fit none

parent 6c925a21
...@@ -475,6 +475,25 @@ cc.Class({ ...@@ -475,6 +475,25 @@ cc.Class({
this.node.y = (this.node.height * this.node.scale) / 2; this.node.y = (this.node.height * this.node.scale) / 2;
return; return;
} }
if (!canvasComponent.fitHeight && !canvasComponent.fitWidth) {
console.log("fit width");
const scale = Math.min(
designSize.width / canvasSize.width,
designSize.height / canvasSize.height
);
const scaleHeight = this.node.height / canvasSize.height;
this.node.width = canvasSize.width * scaleHeight;
this.node.scale = scale / scaleHeight;
const pos = this.node.parent.convertToNodeSpaceAR(
canvas.convertToWorldSpaceAR(cc.v2(0, 0))
);
this.node.setPosition(pos);
return;
}
}, },
exit() { exit() {
......
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