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

Make video thumbnails have certain height before image loading starts to avoid layout shifts #4723

Merged

Conversation

PikachuEXE
Copy link
Collaborator

@PikachuEXE PikachuEXE commented Feb 27, 2024

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Similar to #4713

Description

As title
The constant aspect ratio is only applied before image loading finished (no idea how to detect image loading start) in case the image got different aspect ratio

Screenshots

Image loading not started yet
image

Image loaded started
image

Testing

  • Turn off Replace HTTP Cache (so that renderer does the image loading)
  • In dev tool change network speed to slow 3G
  • Find some random playlist to load (user playlist might be faster)
  • Ensure thumbnail element got height before image loading starts

Desktop

  • OS:
  • OS Version:
  • FreeTube version:

Additional context

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Feb 27, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 27, 2024 01:21

.thumbnailImage.thumbnailLoading {
// Makes img element sized correctly before image loading starts
aspect-ratio: 16 / 9;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the aspect-ratio docs on MDN, you can do this for images, which will make it use 16/9 until the image is downloaded and after that use the image's aspect ratio.

That would allow you to remove the javascript and the thumbnail loading class.

Suggested change
aspect-ratio: 16 / 9;
aspect-ratio: 16/9 auto;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it's done

@FreeTubeBot FreeTubeBot merged commit c386841 into FreeTubeApp:development Mar 1, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 1, 2024
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Mar 4, 2024
* development: (29 commits)
  Translated using Weblate (Chinese (Traditional))
  Fix URL copied via right click menu (FreeTubeApp#4690)
  Translated using Weblate (Croatian)
  Wrap ft-icon buttons below before they go fully vertical (FreeTubeApp#4735)
  * Make activating a chapter selector makes window scroll to top like clicking on timestamp links (FreeTubeApp#4722)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Make video thumbnails have certain height before image loading starts to avoid layout shifts (FreeTubeApp#4723)
  Update subscription cache when visiting a channel (FreeTubeApp#4667)
  Fix fallback to Invidious for the podcasts channel tab (FreeTubeApp#4731)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Arabic)
  Translated using Weblate (Polish)
  Translated using Weblate (Dutch)
  Translated using Weblate (Icelandic)
  Translated using Weblate (Spanish)
  Translated using Weblate (Arabic)
  Translated using Weblate (Icelandic)
  Translated using Weblate (Italian)
  Translated using Weblate (Chinese (Simplified))
  ...
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Mar 7, 2024
* development: (161 commits)
  Add video search in user playlist feature (FreeTubeApp#4622)
  Add discussion info when opening an issue (FreeTubeApp#4676)
  Translated using Weblate (Lithuanian)
  Translated using Weblate (Serbian)
  Translated using Weblate (Estonian)
  Bump mini-css-extract-plugin from 2.8.0 to 2.8.1 (FreeTubeApp#4742)
  Bump electron from 28.2.3 to 29.1.0 (FreeTubeApp#4743)
  Bump lefthook from 1.6.1 to 1.6.4 (FreeTubeApp#4740)
  Bump the babel group with 2 updates (FreeTubeApp#4739)
  Bump swiper from 11.0.6 to 11.0.7 (FreeTubeApp#4741)
  Bump electron-builder from 24.12.0 to 24.13.3 (FreeTubeApp#4744)
  Split view count and published date into two lines on small displays (FreeTubeApp#4736)
  Translated using Weblate (Chinese (Traditional))
  Fix URL copied via right click menu (FreeTubeApp#4690)
  Translated using Weblate (Croatian)
  Wrap ft-icon buttons below before they go fully vertical (FreeTubeApp#4735)
  * Make activating a chapter selector makes window scroll to top like clicking on timestamp links (FreeTubeApp#4722)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Make video thumbnails have certain height before image loading starts to avoid layout shifts (FreeTubeApp#4723)
  ...

# Conflicts:
#	src/renderer/views/Playlist/Playlist.vue
@PikachuEXE PikachuEXE deleted the feature/playlist-layout-shift branch April 2, 2024 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants