forked from github/dataease
refactor(数据大屏): 调整跑马灯滚动速度逻辑,防止不同宽度速度可能不一致问题,调整速度范围
This commit is contained in:
parent
21f52cb9e5
commit
f8115dcbf5
@ -353,7 +353,9 @@ const scrollSpeedList = [
|
|||||||
{ name: '70', value: 70 },
|
{ name: '70', value: 70 },
|
||||||
{ name: '80', value: 80 },
|
{ name: '80', value: 80 },
|
||||||
{ name: '90', value: 90 },
|
{ name: '90', value: 90 },
|
||||||
{ name: '100', value: 100 }
|
{ name: '100', value: 100 },
|
||||||
|
{ name: '150', value: 150 },
|
||||||
|
{ name: '200', value: 200 }
|
||||||
]
|
]
|
||||||
|
|
||||||
const opacitySizeList = [
|
const opacitySizeList = [
|
||||||
|
@ -16,6 +16,7 @@ const textOut = ref(null)
|
|||||||
const scrollScale0 = ref('100%')
|
const scrollScale0 = ref('100%')
|
||||||
const scrollScale100 = ref('100%')
|
const scrollScale100 = ref('100%')
|
||||||
let timeId = null
|
let timeId = null
|
||||||
|
const textOutClientWidth = ref(200)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
propValue: {
|
propValue: {
|
||||||
@ -134,9 +135,7 @@ const varStyle = computed(() => [
|
|||||||
'--scroll-speed': `${
|
'--scroll-speed': `${
|
||||||
element.value.style.scrollSpeed === 0 || !textOut.value
|
element.value.style.scrollSpeed === 0 || !textOut.value
|
||||||
? 0
|
? 0
|
||||||
: (textOut.value.clientWidth * 100) /
|
: (textOutClientWidth.value + text.value.clientWidth) / element.value.style.scrollSpeed
|
||||||
canvasStyleData.value.scale /
|
|
||||||
element.value.style.scrollSpeed
|
|
||||||
}s`,
|
}s`,
|
||||||
'--scroll-scale0': `${scrollScale0.value}`,
|
'--scroll-scale0': `${scrollScale0.value}`,
|
||||||
'--scroll-scale100': `${scrollScale100.value}`
|
'--scroll-scale100': `${scrollScale100.value}`
|
||||||
@ -152,8 +151,8 @@ const init = () => {
|
|||||||
const componentOut = document.getElementById(outerId)
|
const componentOut = document.getElementById(outerId)
|
||||||
if (componentOut && text.value) {
|
if (componentOut && text.value) {
|
||||||
const textValue = text.value.clientWidth
|
const textValue = text.value.clientWidth
|
||||||
const textOutValue = componentOut.clientWidth
|
textOutClientWidth.value = componentOut.clientWidth
|
||||||
scrollScale0.value = (textOutValue * 100) / textValue + '%'
|
scrollScale0.value = (textOutClientWidth.value * 100) / textValue + '%'
|
||||||
scrollScale100.value = '-100%'
|
scrollScale100.value = '-100%'
|
||||||
} else {
|
} else {
|
||||||
scrollScale0.value = '100%'
|
scrollScale0.value = '100%'
|
||||||
@ -161,13 +160,6 @@ const init = () => {
|
|||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const textStyle = computed(() => {
|
|
||||||
return {
|
|
||||||
verticalAlign: element.value['style'].verticalAlign
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
@ -188,7 +180,6 @@ onMounted(() => {
|
|||||||
:contenteditable="canEdit"
|
:contenteditable="canEdit"
|
||||||
:class="{ 'can-edit': canEdit, 'marquee-txt': marqueeTxt }"
|
:class="{ 'can-edit': canEdit, 'marquee-txt': marqueeTxt }"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
:style="textStyle"
|
|
||||||
@paste="clearStyle"
|
@paste="clearStyle"
|
||||||
@mousedown="handleMousedown"
|
@mousedown="handleMousedown"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
@ -197,7 +188,7 @@ onMounted(() => {
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="v-text preview" ref="textOut" :style="varStyle">
|
<div v-else class="v-text preview" ref="textOut" :style="varStyle">
|
||||||
<div class="marquee-txt" :style="textStyle" ref="text" v-html="element['propValue']"></div>
|
<div class="marquee-txt" ref="text" v-html="element['propValue']"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -205,11 +196,9 @@ onMounted(() => {
|
|||||||
.v-text {
|
.v-text {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: table;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
div {
|
div {
|
||||||
display: table-cell;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -218,6 +207,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
.can-edit {
|
.can-edit {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user