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
JS
transition end classes are applied at incorrect time (add_class
, remove_class
, and transition
)
#2484
Comments
Thank you Chris and José for the wonderful |
Thanks for the thorough issue and recreation. As a sanity check, I released a fix to 0.18.15 for transition, but you are using that here. Can you verify if the behavior you were seeing changed between 0.18.14 and 0.18.15? I'll take a look soon. Thanks! |
Thanks for your quick response, @chrismccord! I did notice the bugfix in No, this behavior has not changed between Thank you for your help! 🙇♂️ 🙌 |
JS
transition end classes applied at incorrect time (add_class
, remove_class
, and transition
)JS
transition end classes are applied at incorrect time (add_class
, remove_class
, and transition
)
Will this fix affect the timing on My code: <a href="#"
class="underline"
phx-click={
JS.toggle(
to: "#buttons-block",
display: "flex",
in: "fade-in-scale",
out: "fade-out-scale",
time: 500
)
}>
.fade-in-scale {
animation: fade-in-scale 500ms cubic-bezier(0.45, 0, 0.55, 1) 0s 1 normal forwards;
}
@keyframes fade-in-scale {
0% {
transform: scaleY(0);
}
100% {
transform: scaleY(1);
}
}
.fade-out-scale {
animation: fade-out-scale 500ms cubic-bezier(0.45, 0, 0.55, 1) 0s 1 normal forwards;
}
@keyframes fade-out-scale {
0% {
transform: scaleY(1);
}
100% {
transform: scaleY(0);
}
} |
The same issue also occurred in version 0.18.18. |
I created a PR (#2622) for this issue. And the preview of the solution looks like this: My.Movie.mp4 |
updated `:phoenix_live_view` to 0.20.0 to leverage the bug fix for issue phoenixframework/phoenix_live_view#2484 - removed `preload/1` callback in favor of `update_many/1` in `LantternWeb.AssessmentPointEntryEditorComponent` (preload was deprecated in 0.20.0) - adjusted `LantternWeb.AssessmentPointLiveTest` date assertion regex
Environment
Terminology
JS
refers toPhoenix.LiveView.JS
.time
refers to the:time
option given to aJS
function.transition_classes
,start
, andend
refer to the{transition_classes, start, end}
tuple given as the:transition
option for aJS
function.Actual behavior
When using
JS.add_class
,JS.remove_class
, andJS.transition
, theend
classes are not applied untiltime
has expired. Furthermore, they are never removed from the element.In other words:
transition_classes
andstart
classes are immediately added.time
milliseconds, theend
classes are added and thetransition_classes
andstart
classes are removed.Expected behavior
When using
JS.add_class
,JS.remove_class
, andJS.transition
, theend
classes are applied immediately after thestart
classes. Theend
classes are removed aftertime
has expired. This behavior would be consistent withJS.show
,JS.hide
, andJS.toggle
.In other words:
start
classes are added.transition_classes
are added.end
classes are added and thestart
classes are removed.time
milliseconds, thetransition_classes
andend
classes are removed.Reference of Correct Implementation
The Expected Behavior is precisely how the
toggle
function inphoenix_live_view.js
already works. This explains whyJS.show
,JS.hide
, andJS.toggle
behave correctly, since they all use that function behind the scenes.phoenix_live_view/priv/static/phoenix_live_view.js
Lines 2337 to 2350 in 82b3492
Example LiveView
Clone this repository and run:
Then, open your browser to: http://localhost:5001
This runs a LiveView that demonstrates the inconsistent behavior using TailwindCSS classes. Note the
mount
andrender
functions inSamplePhoenix.SampleLive
in live_view.exs.Video Demonstration
This video shows what happens when you run the above example LiveView.
The
:transition
option is identical for everyJS
function call (withstart
andend
sometimes flipped):However, only
JS.toggle
,JS.show
, andJS.hide
correctly cause the opacity to transition smoothly.Screen.Recording.2023-02-23.at.1.09.01.PM.mov
The text was updated successfully, but these errors were encountered: