fix: 系统名称横向滚动衔接动画

This commit is contained in:
TsMask
2024-07-16 11:21:16 +08:00
parent 79920542c1
commit a2d93ddafe
3 changed files with 54 additions and 29 deletions

View File

@@ -176,6 +176,7 @@ function fnCheckAppNameOverflow() {
if (!text) return;
if (text.offsetWidth > container.offsetWidth) {
text.classList.add('app-name_scrollable');
text.setAttribute('data-content', text.innerText);
} else {
text.classList.remove('app-name_scrollable');
}
@@ -382,20 +383,26 @@ onUnmounted(() => {
// text-overflow: ellipsis;
white-space: nowrap;
width: 148px;
&_scrollable {
// padding-left: 100%;
> .app-name_scrollable {
padding-right: 12px;
display: inline-block;
animation: scrollable-animation linear 6s infinite both;
}
@keyframes scrollable-animation {
0% {
transform: translate3d(0, 0, 0);
&::after {
content: attr(data-content);
position: absolute;
top: 0;
right: -100%;
transition: right 0.3s ease;
}
100% {
transform: translate3d(-100%, 0, 0);
@keyframes scrollable-animation {
0% {
transform: translateX(0);
}
100% {
transform: translateX(calc(-100% - 12px));
}
}
}
}

View File

@@ -206,6 +206,7 @@ function fnCheckAppNameOverflow() {
if (!text) return;
if (text.offsetWidth > container.offsetWidth) {
text.classList.add('app-name_scrollable');
text.setAttribute('data-content', text.innerText);
} else {
text.classList.remove('app-name_scrollable');
}
@@ -398,18 +399,25 @@ onMounted(() => {
font-size: 18px;
> .app-name_scrollable {
// padding-left: 100%;
padding-right: 12px;
display: inline-block;
animation: scrollable-animation linear 6s infinite both;
}
@keyframes scrollable-animation {
0% {
transform: translate3d(0, 0, 0);
&::after {
content: attr(data-content);
position: absolute;
top: 0;
right: -100%;
transition: right 0.3s ease;
}
100% {
transform: translate3d(-100%, 0, 0);
@keyframes scrollable-animation {
0% {
transform: translateX(0);
}
100% {
transform: translateX(calc(-100% - 12px));
}
}
}
}

View File

@@ -184,12 +184,15 @@ watch(
/**检查系统名称是否超出范围进行滚动 */
function fnCheckAppNameOverflow() {
const container: HTMLDivElement | null = document.querySelector('.header-icon > .app-name');
const container: HTMLDivElement | null = document.querySelector(
'.header-icon > .app-name'
);
if (!container) return;
const text: HTMLDivElement | null = container.querySelector('.marquee');
if (!text) return;
if (text.offsetWidth > container.offsetWidth) {
text.classList.add('app-name_scrollable');
text.setAttribute('data-content', text.innerText);
} else {
text.classList.remove('app-name_scrollable');
}
@@ -201,7 +204,7 @@ watch(
);
onMounted(() => {
fnCheckAppNameOverflow()
fnCheckAppNameOverflow();
Object.assign(state, {
language: currentLocale.value,
filePath: '',
@@ -360,20 +363,27 @@ onMounted(() => {
margin: 0 0 0 12px;
font-weight: 600;
font-size: 18px;
> .app-name_scrollable {
// padding-left: 100%;
padding-right: 12px;
display: inline-block;
animation: scrollable-animation linear 6s infinite both;
}
@keyframes scrollable-animation {
0% {
transform: translate3d(0, 0, 0);
&::after {
content: attr(data-content);
position: absolute;
top: 0;
right: -100%;
transition: right 0.3s ease;
}
100% {
transform: translate3d(-100%, 0, 0);
@keyframes scrollable-animation {
0% {
transform: translateX(0);
}
100% {
transform: translateX(calc(-100% - 12px));
}
}
}
}