mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
feat: 拖拽按住shift键限制水平或垂直移动
This commit is contained in:
parent
bee403bc70
commit
91041be25c
@ -1,6 +1,6 @@
|
||||
import { Ref } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useMainStore, useSlidesStore } from '@/store'
|
||||
import { useMainStore, useSlidesStore, useKeyboardStore } from '@/store'
|
||||
import { PPTElement } from '@/types/slides'
|
||||
import { AlignmentLineProps } from '@/types/edit'
|
||||
import { VIEWPORT_SIZE } from '@/configs/canvas'
|
||||
@ -14,6 +14,7 @@ export default (
|
||||
) => {
|
||||
const slidesStore = useSlidesStore()
|
||||
const { activeElementIdList, activeGroupElementId } = storeToRefs(useMainStore())
|
||||
const { shiftKeyState } = storeToRefs(useKeyboardStore())
|
||||
const { viewportRatio } = storeToRefs(slidesStore)
|
||||
|
||||
const { addHistorySnapshot } = useHistorySnapshot()
|
||||
@ -123,8 +124,13 @@ export default (
|
||||
}
|
||||
if (!isMouseDown || isMisoperation) return
|
||||
|
||||
const moveX = (currentPageX - startPageX) / canvasScale.value
|
||||
const moveY = (currentPageY - startPageY) / canvasScale.value
|
||||
let moveX = (currentPageX - startPageX) / canvasScale.value
|
||||
let moveY = (currentPageY - startPageY) / canvasScale.value
|
||||
|
||||
if (shiftKeyState.value) {
|
||||
if (Math.abs(moveX) > Math.abs(moveY)) moveY = 0
|
||||
if (Math.abs(moveX) < Math.abs(moveY)) moveX = 0
|
||||
}
|
||||
|
||||
// 基础目标位置
|
||||
let targetLeft = elOriginLeft + moveX
|
||||
|
Loading…
x
Reference in New Issue
Block a user