mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(ellipsis animation): dots could appear cut off and cause displacement changing width of string
This commit is contained in:
@@ -1,22 +1,52 @@
|
|||||||
|
.nowrap {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ellipsis {
|
||||||
|
display: inline-block;
|
||||||
|
width: 4ch;
|
||||||
|
}
|
||||||
|
|
||||||
.ellipsis:after {
|
.ellipsis:after {
|
||||||
overflow: hidden;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: absolute;
|
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
-webkit-animation: ellipsis steps(4,end) 1500ms infinite;
|
-webkit-animation: ellipsis 1500ms steps(4, end) infinite;
|
||||||
animation: ellipsis steps(4,end) 1500ms infinite;
|
animation: ellipsis 1500ms steps(4, end) infinite;
|
||||||
content: "\2026"; /* ascii code for the ellipsis character */
|
content: "";
|
||||||
width: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes ellipsis {
|
@keyframes ellipsis {
|
||||||
to {
|
0% {
|
||||||
width: 1.25em;
|
content: "";
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
content: ".";
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
content: "..";
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
content: "...";
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
content: "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@-webkit-keyframes ellipsis {
|
@-webkit-keyframes ellipsis {
|
||||||
to {
|
0% {
|
||||||
width: 1.25em;
|
content: "";
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
content: ".";
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
content: "..";
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
content: "...";
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
content: "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,20 @@ interface LoadingEllipsisProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LoadingEllipsis = ({ string }: LoadingEllipsisProps) => {
|
const LoadingEllipsis = ({ string }: LoadingEllipsisProps) => {
|
||||||
return <span className={styles.ellipsis}>{string}</span>;
|
const words = string.split(' ');
|
||||||
|
const lastWord = words.pop();
|
||||||
|
const restOfString = words.join(' ');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{restOfString}
|
||||||
|
{restOfString && ' '}
|
||||||
|
<span className={styles.nowrap}>
|
||||||
|
{lastWord}
|
||||||
|
<span className={styles.ellipsis} />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LoadingEllipsis;
|
export default LoadingEllipsis;
|
||||||
|
|||||||
Reference in New Issue
Block a user