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

Fix attempt for race condition in JS.show() #3455

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

silverdr
Copy link
Contributor

@silverdr silverdr commented Oct 5, 2024

Attempted fix for issue: #3456

Please note that I am not familiar with the codebase and cannot be sure that this is the "correct" way to address the issue.

Description:

When trying to use JS.hide() / JS.show() with animated transitions, there is a race condition in JS.show(), between applying display: <value> and the transition class(es). As a result the transition flow can be disturbed.

example video showing the problem:

https://cld.silverdr.com/s/z8KbZkCDGw8Ffyx

for

phx-click={JS.show(to: "#window-title-window", transition: "fade-in-scale", display: "flex")}

and transition CSS:

@keyframes fade-in-scale {
	0% {
		transform: scale(0.4) translateY(25px);
		opacity: 0;
	}

	90% {
		transform: scale(1.05) translateY(-3px);
		opacity: 0.9;
	}

	100%{
		transform: scale(1.0) translateY(0px);
		opacity: 1;
	}
}

.fade-in-scale {
	animation-direction: normal;
	animation-duration: .2s;
	animation-fill-mode: forwards;
	animation-name: fade-in-scale;
}

Relevant elixirforum.com thread:

https://elixirforum.com/t/liveview-js-show-hide-race-condition/66405/

@silverdr silverdr changed the title Quick fix for race condition in JS.show() Fix attempt for race condition in JS.show() Oct 19, 2024
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.

1 participant