Skip to content

Commit

Permalink
更新缩放
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Dec 5, 2023
1 parent 885148c commit da0d1ea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hooks/useCanvasScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useElementBounding } from '@vueuse/core'
import { Group, Point } from 'fabric'
import useCanvas from '@/views/Canvas/useCanvas'
import useCenter from '@/views/Canvas/useCenter'
import { WorkSpaceThumbType } from '@/configs/canvas'

export default () => {
const fabricStore = useFabricStore()
Expand Down Expand Up @@ -88,7 +89,7 @@ export default () => {
// canvas.setDimensions({width: width.value, height: height.value})
// canvas.renderAll()
const { zoom } = storeToRefs(fabricStore)
const objects = canvas.getObjects()
const objects = canvas.getObjects().filter(ele => !WorkSpaceThumbType.includes(ele.id))
const boundingBox = Group.prototype.getObjectsBoundingBox(objects)
if (!boundingBox) return
zoom.value = Math.min(canvas.getWidth() / boundingBox.width, canvas.getHeight() / boundingBox.height,) * scalePercentage.value / 100
Expand Down

0 comments on commit da0d1ea

Please sign in to comment.