Skip to content

Commit 16abc0e

Browse files
authored
chore: update animation for image profile (#68)
1 parent 7719131 commit 16abc0e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/card.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ export default function cardStyle(data: GetData, uiConfig: UiConfig): string {
99
const defaultLocale: Locales[keyof Locales] = locales[fallbackLocale];
1010
const selectLocale: Locales[keyof Locales] = locales[uiConfig.Locale] || defaultLocale;
1111

12+
const isRtlDirection = parseBoolean(selectLocale.rtlDirection);
13+
const isDisabledAnimations = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png");
14+
15+
const direction = isRtlDirection ? "rtl" : "ltr";
16+
const titleXAngle = isDisabledAnimations ? (isRtlDirection ? 520 : 15) : (isRtlDirection ? 510 : 5);
17+
const titleYAngle = isDisabledAnimations ? 0 : -10;
18+
const textXAngle = isRtlDirection ? 215 : 25;
19+
const dataXAngle = isRtlDirection ? 15 : 225;
20+
const iconXAngle = isRtlDirection ? 225 : 0;
21+
const imageXAngle = isDisabledAnimations ? 120 : 125;
22+
const imageYAngle = isDisabledAnimations ? 70 : 65;
23+
const userXAngle = isDisabledAnimations ? 119.9 : 109.9;
24+
const userYAngle = isDisabledAnimations ? 140 : 130;
25+
const follXAngle = isDisabledAnimations ? 120 : 110;
26+
const follYAngle = isDisabledAnimations ? 161 : 151;
1227
const animations = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png") ? `` : ` /* Animations */
1328
@keyframes scaleInAnimation {
1429
from {
@@ -42,30 +57,15 @@ export default function cardStyle(data: GetData, uiConfig: UiConfig): string {
4257
}
4358
4459
.image-profile-animation {
45-
animation: scaleInAnimation 0.9s ease-in-out forwards;
60+
animation: scaleInAnimation 1.2s ease-in-out forwards;
61+
transform-origin: ${imageXAngle}px ${imageYAngle}px;
4662
}
4763
4864
.single-item-animation {
4965
opacity: 0;
5066
animation: fadeInAnimation 0.3s ease-in-out forwards;
5167
}`;
5268

53-
const isRtlDirection = parseBoolean(selectLocale.rtlDirection);
54-
const isDisabledAnimations = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png");
55-
56-
const direction = isRtlDirection ? "rtl" : "ltr";
57-
const titleXAngle = isDisabledAnimations ? (isRtlDirection ? 520 : 15) : (isRtlDirection ? 510 : 5);
58-
const titleYAngle = isDisabledAnimations ? 0 : -10;
59-
const textXAngle = isRtlDirection ? 215 : 25;
60-
const dataXAngle = isRtlDirection ? 15 : 225;
61-
const iconXAngle = isRtlDirection ? 225 : 0;
62-
const imageXAngle = isDisabledAnimations ? 120 : 125;
63-
const imageYAngle = isDisabledAnimations ? 70 : 65;
64-
const userXAngle = isDisabledAnimations ? 119.9 : 109.9;
65-
const userYAngle = isDisabledAnimations ? 140 : 130;
66-
const follXAngle = isDisabledAnimations ? 120 : 110;
67-
const follYAngle = isDisabledAnimations ? 161 : 151;
68-
6969
const hiddenItems = uiConfig.hiddenItems || "";
7070
const hiddenItemsArray = hiddenItems.split(",");
7171
const showItems = uiConfig.showItems || "";

0 commit comments

Comments
 (0)