[bug]: transitioning background with gradient causes error

オープン
#2,318 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
css, react, typescript
領域
frontend, web-dev

調査の方向性

@react-spring/web ターゲットから始め、useSprings と sidebarApi.start を使った提供された例で、リンク先の CodeSandbox で失敗を再現します。単色、グラデーション、または oklch() を拒否する背景値の補間を追跡し、単色からグラデーションへの遷移でエラーが発生したり予期せず跳ねたりしなくなったら、issue は完了とします。

索引モデルが issue の本文から書いたものです。

説明

area: core kind: bug
Which react-spring target are you using?
  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog
What version of react-spring are you using?

9.7.4

What's Wrong?

When using background css property as a spring value and trying to transition it produces an error when being transitioned with a gradient.

Uncaught (in promise) Error: Cannot animate between _J and HJ, as the "to" prop suggests
    at v0._merge (chunk-sdxbpvym.js:1:33453)
    at E (chunk-sdxbpvym.js:1:20623)
    at U (chunk-sdxbpvym.js:1:20503)
    at chunk-sdxbpvym.js:1:20302
    at new Promise (<anonymous>)
    at TZ (chunk-sdxbpvym.js:1:20074)
    at v0._update (chunk-sdxbpvym.js:1:32158)
    at chunk-sdxbpvym.js:1:31167
    at Array.map (<anonymous>)
    at v0.start (chunk-sdxbpvym.js:1:31145)
The arity of each "output" value must be equal
HTMLUnknownElement.callCallback
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:4164:14
Object.invokeGuardedCallbackDev
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:4213:16
invokeGuardedCallback
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:4277:31
invokeGuardedCallbackAndCatchFirstError
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:4291:25
executeDispatch
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9041:3
processDispatchQueueItemsInOrder
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9073:7
processDispatchQueue
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9086:5
dispatchEventsForPlugins
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9097:3
eval
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9288:12
batchedUpdates$1
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:26140:12
batchedUpdates
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:3991:12
dispatchEventForPluginEventSystem
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:9287:3
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:6465:5
dispatchEvent
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:6457:5
dispatchDiscreteEvent
https://hpj9rs.csb.app/node_modules/react-dom/cjs/react-dom.development.js:6430:5
To Reproduce

Create a spring similar to the following and use the api to start transitioning to a gradient. The colors do not have to be oklch but there is an additional bug where using oklch makes the animation jump from a plain color right to the gradient without transition.

//numItems: number

const [sidebarSprings, sidebarApi] = useSprings(numItems, () => ({
  background: '#eaeaea',
  color: '#2c2c2c',
}));

// index: number

sidebarApi.start((i) => {
return {
  background: i === index ? 'linear-gradient(to right, oklch(0.6 0.14 305), oklch(0.6 0.14 260))' : '#eaeaea',
  color: i === index ? '#ffffff' : '#2c2c2c',
  };
});
Expected Behaviour

I expect that I can transition from a solid color background into a gradient smoothly. It is possible to make a workaround where you return a new gradient string to transition the gradient however it still does not transition it instantly applies changes. This workaround does not work for some colors like when using oklch(). It should be possible to transition background gradient colors smoothly.

Link to repo

https://codesandbox.io/p/sandbox/hpj9rs

主要言語
TypeScript
スター
29.3k
フォーク
1.2k
平均マージ
3日 15時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pmndrs/react-spring のほかの issue

pmndrs/react-spring の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。