open-ui icon indicating copy to clipboard operation
open-ui copied to clipboard

selectlist: Animating changes in the selected value

Open josepharhar opened this issue 2 years ago • 5 comments

I was talking to @argyleink about how the <selectedoption> element sets new values in https://github.com/openui/open-ui/issues/571#issuecomment-1696637459 and he was interested in whether the author could create a transition or a view transition when the <selectedoption> content changes. Maybe this is something we could find a way to support?

josepharhar avatar Aug 31 '23 16:08 josepharhar

UA styles are like:

selectedoption {
  view-transition-name: none;
}

But author styles are like, no way, lemme animate:

.color-picker selectedoption {
  view-transition-name: selected-color-option;
}

::view-transition-new(selected-color-option) {
  animation: var(--slide-in-up);
}

::view-transition-old(selected-color-option) {
  animation: var(--slide-out-up);
}

argyleink avatar Aug 31 '23 17:08 argyleink

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.

github-actions[bot] avatar Feb 28 '24 00:02 github-actions[bot]

I'm not sure exactly what browser support would be needed in order for this to work. @argyleink would you need to have a UA style rule with view-transition-name?

josepharhar avatar Mar 21 '24 18:03 josepharhar

hm, might not be that simple because there could be multiple on the page. doesnt seem a good idea for the UA to attempt multiple unique view transition names for selected options. the intent of this issue is good, but the strategy being offered via the UA and VT, isnt.

argyleink avatar Mar 21 '24 18:03 argyleink

@starting-style and transition: display 1s allow-discrete doesn't seem to work here, should we support it?

yisibl avatar May 29 '24 07:05 yisibl

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.

github-actions[bot] avatar Nov 26 '24 00:11 github-actions[bot]

I was able to animate a change in the selected value here: https://codepen.io/jarhar/pen/PwYbmrp?editors=0100

josepharhar avatar Dec 13 '24 23:12 josepharhar

I was able to animate a change in the selected value here: https://codepen.io/jarhar/pen/PwYbmrp?editors=0100

that animates the new choice in, but not out. so there's no crossfade, it's a bit abrupt. but it's better than nothing, and my selects are using this also to make the choice a little less abrupt.

argyleink avatar Dec 16 '24 15:12 argyleink

Is there more work needed here or can this be closed?

lukewarlow avatar May 11 '25 10:05 lukewarlow

Supporting view transitions for builtin elements like this is something that would be nice to add in the future, for select and other elements.

For now, if you want to make a view transition, you'll have to implement <selectedcontent> manually with script. Here's an example: https://codepen.io/jarhar/pen/pvvGzOe?editors=1111

josepharhar avatar May 13 '25 18:05 josepharhar