Skip to content

Commit 29f77da

Browse files
committed
PrestakingWelcome: implement designer feedback
The prestaking welcome page now behave like an “instagram story” or something the like.
1 parent 9a1412a commit 29f77da

File tree

3 files changed

+543
-248
lines changed

3 files changed

+543
-248
lines changed

src/components/StepProgressBar.vue

+20-16
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@ export default defineComponent({
2222
type: Number,
2323
required: true,
2424
},
25+
shouldAnimate: {
26+
type: Boolean,
27+
default: true,
28+
},
2529
},
26-
setup(props) {
27-
const animationProgress = ref(0);
30+
setup(props, { emit }) {
31+
const animationProgress = ref(100); // Start with full progress
2832
const isFirstStepAnimated = ref(false);
29-
const ANIMATION_DURATION = 1500; // 1500ms = 1.5s
33+
const ANIMATION_DURATION = 5000; // 5000ms = 5s (adjust as needed)
3034
3135
const getFillWidth = computed(() => (step: number) => {
3236
if (props.currentStep > step) return '100%';
3337
if (props.currentStep === step) {
34-
// Apply easing function to the animation progress
35-
const easedProgress = easeOutCubic(animationProgress.value / 100) * 100;
36-
return `${easedProgress}%`;
38+
return props.shouldAnimate ? `${animationProgress.value}%` : '100%';
3739
}
3840
return '0%';
3941
});
4042
41-
// Easing function: easeOutCubic
42-
const easeOutCubic = (t: number): number => 1 - (1 - t) ** 3;
43-
4443
let animationFrame: number;
44+
let animationStartTime: number | null = null;
4545
4646
const animateStep = (timestamp: number) => {
4747
if (!animationStartTime) {
@@ -51,26 +51,30 @@ export default defineComponent({
5151
const progress = Math.min(elapsed / ANIMATION_DURATION, 1);
5252
animationProgress.value = progress * 100;
5353
54-
if (progress < 1) {
54+
if (progress < 1 && props.shouldAnimate) {
5555
animationFrame = requestAnimationFrame(animateStep);
5656
} else {
5757
isFirstStepAnimated.value = true;
58+
emit('stepCompleted');
5859
}
5960
};
6061
61-
let animationStartTime: number | null = null;
62-
6362
const startAnimation = () => {
64-
animationStartTime = null;
65-
cancelAnimationFrame(animationFrame);
66-
animationFrame = requestAnimationFrame(animateStep);
63+
if (props.shouldAnimate) {
64+
animationStartTime = null;
65+
cancelAnimationFrame(animationFrame);
66+
animationProgress.value = 0; // Reset progress before starting animation
67+
animationFrame = requestAnimationFrame(animateStep);
68+
} else {
69+
animationProgress.value = 100; // Set to full progress immediately
70+
}
6771
};
6872
6973
watch(() => props.currentStep, (newStep, oldStep) => {
7074
if (newStep > oldStep || (newStep === 1 && !isFirstStepAnimated.value)) {
7175
startAnimation();
7276
} else if (newStep < oldStep) {
73-
animationProgress.value = 0;
77+
animationProgress.value = 100; // Set to full progress when going back
7478
}
7579
});
7680

0 commit comments

Comments
 (0)