Merge pull request #10224 from dataease/pr@dev-v2@refactor_scroll-text-speed2

refactor(数据大屏): 优化跑马灯的滚动速度计算方式,以px为单位同时兼顾缩放的效果
This commit is contained in:
王嘉豪 2024-06-12 16:02:51 +08:00 committed by GitHub
commit 771aef9607
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 13 deletions

View File

@ -508,6 +508,7 @@ const handleMouseDownOnShape = e => {
dashboardActive.value &&
(isFirst || (!tabMoveInActiveId.value && !tabCollisionActiveId.value))
) {
element.value['dragging'] = true
emit('onDragging', e)
}
@ -543,6 +544,7 @@ const handleMouseDownOnShape = e => {
const up = () => {
dashboardActive.value && emit('onMouseUp')
element.value['dragging'] = false
hasMove && snapshotStore.recordSnapshotCache('shape-handleMouseDownOnShape-up')
// 线
eventBus.emit('unMove')
@ -699,6 +701,7 @@ const handleMouseDownOnPoint = (point, e) => {
dvMainStore.setShapeStyle(style, areaData.value.components, 'resize', baseGroupComponentsRadio)
//
dashboardActive.value && emit('onResizing', moveEvent)
element.value['resizing'] = true
//Group
element.value.component === 'Group' && groupSizeStyleAdaptor(element.value)
//Group resizegroupStyle
@ -712,6 +715,7 @@ const handleMouseDownOnPoint = (point, e) => {
const up = () => {
dashboardActive.value && emit('onMouseUp')
element.value['resizing'] = false
document.removeEventListener('mousemove', move)
document.removeEventListener('mouseup', up)
needSave && snapshotStore.recordSnapshotCache('shape-handleMouseDownOnPoint-up')

View File

@ -316,16 +316,16 @@ const fontFamilyList = [
const scrollSpeedList = [
{ name: '停止', value: 0 },
{ name: '1', value: 80 },
{ name: '2', value: 60 },
{ name: '3', value: 40 },
{ name: '4', value: 30 },
{ name: '5', value: 20 },
{ name: '6', value: 15 },
{ name: '7', value: 10 },
{ name: '8', value: 8 },
{ name: '9', value: 6 },
{ name: '10', value: 3 }
{ name: '10', value: 10 },
{ name: '20', value: 20 },
{ name: '30', value: 30 },
{ name: '40', value: 40 },
{ name: '50', value: 50 },
{ name: '60', value: 60 },
{ name: '70', value: 70 },
{ name: '80', value: 80 },
{ name: '90', value: 90 },
{ name: '100', value: 100 }
]
const opacitySizeList = [

View File

@ -165,6 +165,9 @@ export const commonAttr = {
maintainRadio: false, // 布局时保持宽高比例
aspectRatio: 1, // 锁定时的宽高比例
isShow: true, // 是否显示组件
// 当前组件动作
dragging: false,
resizing: false,
collapseName: [
'position',
'background',

View File

@ -32,7 +32,7 @@ const props = defineProps({
const { element } = toRefs(props)
const dvMainStore = dvMainStoreWithOut()
const { editMode, curComponent } = storeToRefs(dvMainStore)
const { editMode, curComponent, canvasStyleData } = storeToRefs(dvMainStore)
const onComponentClick = () => {
if (curComponent.value.id !== element.value.id) {
@ -94,6 +94,10 @@ const handleBlur = e => {
canEdit.value = false
}
const marqueeTxt = computed(
() => !canEdit.value && !element.value['resizing'] && !element.value['dragging']
)
const setEdit = () => {
if (element.value['isLock']) return
canEdit.value = true
@ -111,7 +115,18 @@ onBeforeUnmount(() => {
eventBus.off('componentClick', onComponentClick)
})
const varStyle = computed(() => [{ '--scroll-speed': `${element.value.style.scrollSpeed}s` }])
// px
const varStyle = computed(() => [
{
'--scroll-speed': `${
element.value.style.scrollSpeed === 0 || !text.value
? 0
: (text.value.clientWidth * 100) /
canvasStyleData.value.scale /
element.value.style.scrollSpeed
}s`
}
])
const textStyle = computed(() => {
return {
@ -131,7 +146,7 @@ const textStyle = computed(() => {
<div
ref="text"
:contenteditable="canEdit"
:class="{ 'can-edit': canEdit, 'marquee-txt': !canEdit }"
:class="{ 'can-edit': canEdit, 'marquee-txt': marqueeTxt }"
tabindex="0"
:style="textStyle"
@dblclick="setEdit"

View File

@ -232,6 +232,8 @@ export const dvMainStore = defineStore('dataVisualization', {
setCurComponent({ component, index }) {
if (!component && this.curComponent) {
this.curComponent['editing'] = false
this.curComponent['resizing'] = false
this.curComponent['dragging'] = false
this.curComponent['canvasActive'] = false
// 如果当前组件不在主画布中 对应的分组的canvasActive 也要设置为false
if (this.curComponent.canvasId !== 'canvas-main') {