File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,14 @@ export const init = (
2929 layersByI . clear ( ) ;
3030 canvasByI . clear ( ) ;
3131 dataURLByI . clear ( ) ;
32+ activatedByI . clear ( ) ;
3233} ;
3334
3435export const iByWay = new Map < Way , number > ( ) ;
3536export const layersByI = new Map < number , oekaki . LayeredCanvas [ ] > ( ) ;
3637export const canvasByI = new Map < number , HTMLCanvasElement > ( ) ;
3738export const dataURLByI = new Map < number , string > ( ) ;
39+ export const activatedByI = new Map < number , oekaki . LayeredCanvas > ( ) ;
3840
3941type Way = {
4042 key : string ;
Original file line number Diff line number Diff line change 2929 const now = anime .layersByI .get ($activeIndex );
3030 if (now ) {
3131 oekaki .setLayers (now );
32- activeLayer = now [now .length - 1 ];
3332 } else {
3433 oekaki .setLayers ([]);
3534 activeLayer = new oekaki .LayeredCanvas (" レイヤー #1" );
3635 }
3736 });
3837
38+ // キャラチップ切り替え時に元のレイヤーを選び直す実装
39+ // TODO: レイヤーが1枚しかないときの新規レイヤー追加時にバグあり
40+ $effect (() => {
41+ const activatedLayer = anime .activatedByI .get ($activeIndex );
42+ if (! activatedLayer || $activeIndex === prevIndex ) {
43+ anime .activatedByI .set ($activeIndex , activeLayer );
44+ } else {
45+ activeLayer = activatedLayer ;
46+ prevIndex = $activeIndex ;
47+ }
48+ });
49+
3950 let pointerupTimestampAfter = $state (0 );
4051 $effect (() => {
4152 if (! initTimestamp || ! pointerupTimestamp ) return ;
You can’t perform that action at this time.
0 commit comments