fix: image crop out of focus

This commit is contained in:
ShawnPhang 2024-03-22 16:16:32 +08:00
parent 6888d85708
commit c95d513f4d
2 changed files with 10 additions and 7 deletions

View File

@ -2,8 +2,8 @@
* @Author: ShawnPhang * @Author: ShawnPhang
* @Date: 2022-02-22 15:06:14 * @Date: 2022-02-22 15:06:14
* @Description: * @Description:
* @LastEditors: ShawnPhang <site: book.palxp.com> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2023-07-03 10:10:53 * @LastEditTime: 2024-03-22 16:00:17
*/ */
// import store from '@/store' // import store from '@/store'
// import { getImage } from '../getImgDetail' // import { getImage } from '../getImgDetail'
@ -30,7 +30,6 @@ export default async function(type: string, item: TCommonItemData, data: Record<
setting.width = img.width setting.width = img.width
setting.height = img.height // parseInt(100 / item.value.ratio, 10) setting.height = img.height // parseInt(100 / item.value.ratio, 10)
setting.imgUrl = item.value.url setting.imgUrl = item.value.url
console.log("setting", setting)
} }
if (type === 'mask') { if (type === 'mask') {
setting.mask = item.value.url setting.mask = item.value.url

View File

@ -3,7 +3,7 @@
* @Date: 2021-08-09 11:41:53 * @Date: 2021-08-09 11:41:53
* @Description: * @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2023-10-09 00:59:44 * @LastEditTime: 2024-03-22 16:14:48
--> -->
<template> <template>
<div id="w-image-style"> <div id="w-image-style">
@ -71,7 +71,7 @@
<script lang="ts" setup> <script lang="ts" setup>
// //
// const NAME = 'w-image-style' // const NAME = 'w-image-style'
import { nextTick, reactive, ref, watch } from 'vue' import { nextTick, reactive, ref, watch, onBeforeUnmount } from 'vue'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import numberInput from '../../settings/numberInput.vue' import numberInput from '../../settings/numberInput.vue'
import iconItemSelect, { TIconItemSelectData } from '../../settings/iconItemSelect.vue' import iconItemSelect, { TIconItemSelectData } from '../../settings/iconItemSelect.vue'
@ -142,14 +142,18 @@ let lastUuid: string | undefined = undefined
let tag: boolean let tag: boolean
let toolBarStyle: { left: string, top: string } | null = null let toolBarStyle: { left: string, top: string } | null = null
onBeforeUnmount(() => {
imgCrop(false)
cropHandle()
})
watch( watch(
() => dActiveElement.value, () => dActiveElement.value,
(newValue, oldValue) => { (newValue, oldValue) => {
change() change()
// //
if (newValue.uuid != lastUuid && typeof lastUuid !== 'undefined') { if (newValue.uuid != lastUuid && typeof lastUuid !== 'undefined') {
state.innerElement.cropEdit = false imgCrop(false)
store.commit('setShowRotatable', true) //
} }
lastUuid = newValue.uuid lastUuid = newValue.uuid
}, },