|
@@ -19,16 +19,35 @@ const config = computed(() => {
|
|
|
if (!props.config.fix) {
|
|
if (!props.config.fix) {
|
|
|
return props.config;
|
|
return props.config;
|
|
|
}
|
|
}
|
|
|
- // return props.config;
|
|
|
|
|
|
|
+
|
|
|
const dec = props.mat.decompose();
|
|
const dec = props.mat.decompose();
|
|
|
- // console.log(props.svg.width, props.svg.height, props.config.box);
|
|
|
|
|
- const config = {
|
|
|
|
|
|
|
+ const invScaleX = dec.scaleX ? 1 / dec.scaleX : 1;
|
|
|
|
|
+ const invScaleY = dec.scaleY ? 1 / dec.scaleY : 1;
|
|
|
|
|
+
|
|
|
|
|
+ // When canceling parent scaling for a sub-path, we must also scale around a
|
|
|
|
|
+ // stable anchor point; otherwise the path shrinks towards (0,0) and drifts.
|
|
|
|
|
+ const box = props.config.box;
|
|
|
|
|
+ const fixCenter = props.config.fixCenter || "";
|
|
|
|
|
+ const ax = fixCenter.includes("L")
|
|
|
|
|
+ ? box.x
|
|
|
|
|
+ : fixCenter.includes("R")
|
|
|
|
|
+ ? box.x + box.width
|
|
|
|
|
+ : box.x + box.width / 2;
|
|
|
|
|
+ const ay = fixCenter.includes("T")
|
|
|
|
|
+ ? box.y
|
|
|
|
|
+ : fixCenter.includes("B")
|
|
|
|
|
+ ? box.y + box.height
|
|
|
|
|
+ : box.y + box.height / 2;
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
...props.config,
|
|
...props.config,
|
|
|
- scaleX: 1 / dec.scaleX,
|
|
|
|
|
- scaleY: 1 / dec.scaleY,
|
|
|
|
|
- // x: props.config.box.x - props.svg.width / 2,
|
|
|
|
|
- // y: props.config.box.y - props.svg.height / 2,
|
|
|
|
|
- };
|
|
|
|
|
- return config;
|
|
|
|
|
|
|
+ scaleX: invScaleX,
|
|
|
|
|
+ scaleY: invScaleY,
|
|
|
|
|
+ // Keep the original svg offset (temp-icon uses svg.x/svg.y as an offset),
|
|
|
|
|
+ // but use (ax, ay) as the scaling origin for this path.
|
|
|
|
|
+ offset: { x: ax, y: ay },
|
|
|
|
|
+ x: ax - props.svg.x,
|
|
|
|
|
+ y: ay - props.svg.y,
|
|
|
|
|
+ } as any;
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|