Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt): loading indicator enhancement #25119

Merged

Conversation

ivan-kalachikov
Copy link
Contributor

@ivan-kalachikov ivan-kalachikov commented Jan 9, 2024

πŸ”— Linked issue

24552

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves: #24552

The problem:

This PR addresses the issue of the loading indicator prematurely reaching 100% when actual page loading exceeds the specified duration, leading to a stagnant indicator and potential user confusion.

Objective:

Improve UX for extended load times: implement a loading indicator that dynamically adjusts its progression, preventing it from indicating 100% completion until the page has fully loaded. This change aims to enhance user experience by providing a more accurate visual representation of the loading status, particularly in longer loading scenarios.

Key Changes:

  • Updated Loading Indicator behavior: Modified the loading indicator to avoid reaching 100% too quickly when the page loading exceeds the specified duration. The indicator now gradually slows down after hitting 50% (by default, can be adjusted with added progressionRate property) progress, ensuring a continuous display of loading progress even during longer load times. This approach provides a more accurate representation of the ongoing loading process.
  • Added property to adjust the function used for calculating the progress value: progressionRate controls the steepness of the non-linear function used in calculating progress. A lower value results in a steeper curve, meaning faster initial progress that slows down more sharply towards the end
  • Progress calculation function: Implemented a new function to calculate the progress value. This function is based on a scaled and shifted arctangent (atan) function, providing a smoother progression curve.

progressTimingFunction

  • Smoothness improvement: Replaced setInterval with requestAnimationFrame for the progress value calculation. This change enhances the smoothness, contributing to better user experience and performance.

Result:

loading-indicator

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Ivan Kalachikov added 2 commits January 9, 2024 13:16
- replace setInterval with RAF - in order to ensure smoother animation and better UX
- implement default timing function based on arctangent trigonometric function - so as to improve UX
- add according prop to accept custom timing function - to enable define custom behavior
Copy link

stackblitz bot commented Jan 9, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions bot added the 3.x label Jan 9, 2024
@ivan-kalachikov ivan-kalachikov changed the title Feat/loading indicator enhancement feat: loading indicator enhancement Jan 9, 2024
Copy link
Contributor

nuxt-studio bot commented Jan 9, 2024

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview de87b58

@ivan-kalachikov ivan-kalachikov marked this pull request as ready for review January 12, 2024 08:08
@ivan-kalachikov
Copy link
Contributor Author

ivan-kalachikov commented Jan 12, 2024

I'm not sure that it can be considered as a new feature, I ticked that type according to the issue name - there is "Feature Request" in the name. Please let me know if it needs to be changed.

@ivan-kalachikov
Copy link
Contributor Author

I've noticed some failed checks that I'm unable to reproduce locally. Could these be related to the changes I made? I'm keen to resolve this issue to help get this PR merged. Any guidance or pointers on what I should focus on would be greatly appreciated.

@martinszeltins
Copy link
Contributor

I am not seeing that much of a difference if I set the progression-rate to 5 or 95 the results are too similar. I wanted to achieve a similar style to how GitHub's progress bar works (reaches 20% and then moves very slowly) but I wasn't able to do that with changing the value of progression-rate. I wish there was more control given to the user to provide a custom timing function or even better if it could be achieved with adjusting the props.

@huang-julien huang-julien changed the title feat: loading indicator enhancement feat(nuxt): loading indicator enhancement Jan 27, 2024
@danielroe danielroe merged commit 90ca0e8 into nuxt:main Jan 29, 2024
36 checks passed
@github-actions github-actions bot mentioned this pull request Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Implement a backing off strategy for <NuxtLoadingIndicator>
4 participants