question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toast dimension might change slightly before transitioning out

See original GitHub issue

Versions

  • 1.7.1

Describe the bug

On closing the toast, the content within the toast might jump around during the hide transition, causing unwanted jumpiness.

Before closing: Screenshot 2020-05-26 at 13 18 12

During closing: Screenshot 2020-05-26 at 13 18 22

Expected behavior

No change in dimensions during hiding.

Steps to reproduce

The bug is very dependant on the content of the popup, font sizes, browser, and some other factors as it’s due to precision loss when using offsetWidth so it’s not easy to create a case that reproduces reliably.

EDIT: This should reproduce: https://codesandbox.io/s/amazing-cherry-wx8n6?file=/src/App.vue

Your Environment

  • OS: macOS
  • Browser Chrome 83

Additional context

The issue is due to using element.style.width = element.offsetWidth + 'px' to “freeze” the width before starting the hide transition. That can cause the size of the toast to change slightly, causing the content to move around.

This is because at least Chrome doesn’t support sub-pixel precision for offsetWidth property so we get values rounded to the full integer that loose some precision. (relevant bug here: https://bugs.chromium.org/p/chromium/issues/detail?id=360889).

A possible way to fix it is to use element.getBoundingClientRect().width (supports sub-pixels) instead but that’s not exactly equivalent to element.offsetWidth as former is affected by transforms while latter not. I’m not sure if there is any other API that could be more relevant here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rchlcommented, May 29, 2020

It does fix my issue. Thank you.

1reaction
Maronatocommented, May 29, 2020

Fix released on 1.7.6. Please give it a try and report back any issues you find 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toasts - Bootstrap
They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a...
Read more >
Create a Simple 0-dependency Toast - DEV Community ‍ ‍
The trick is to use the transition css property on the bottom and animate the change for 350ms. Now I will add a...
Read more >
Toast | Components - BootstrapVue
Toasts will check for the named toaster in the document before they are ... in a <div> with class b-toast to allow for...
Read more >
How to create a custom toast component with React
Here's what the toast notifications will look like after we create ... transition: transform .6s ease-in-out; animation: toast-in-right .7s; ...
Read more >
Bootstrap toasts - CoreUI
You can stack toasts by wrapping them in a toast container, which will vertically add some spacing. Bootstrap just now. See? Just like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found