starwilly / week2-free-cell

0 stars 0 forks source link

想請教兩個問題,如果你可以回答我就太感謝了 #39

Open andynoway253 opened 6 months ago

andynoway253 commented 6 months ago

@starwilly 你好,

我也想練習新接龍這個題目,原本使用原生地 drag 但發現要拖曳複數張牌的動畫做不出來,於是改用了 angular material,但是在把程式clone下來改之後發現...

  1. 把牌面上的每一行排,當作一個列表,在material中,要交換列表中的資料,需要用 [cdkDropListConnectedTo] 屬性互相綁定,可是我沒看到你有這樣做,所以我猜想,是不是直接去更換原始物件,然後讓畫面刷新,在 onCellDropped 這個function中,

if (previousCell !== cell && cell.canAdd(movedCard)) {

在console中印出的結果,previousCell 和 cell 始終是相等的,沒辦法跑接下來的交換,我猜是不是因為沒有互相綁定,所以那怕將撲克牌拖曳到另一行,onCellDropped事件的event也只當作是在自己的行進行拖曳?

  1. '<div class="card-wrapper" ngFor="let card of cell.cards; index as i" [style.top]="i 25 + 'px'" cdkDrag [cdkDragDisabled]="!cell.canMove(card)" [cdkDragData]="{card: card, cell: cell}" (cdkDragStarted)="onDragStart($event)" (cdkDragEnded)="onDragEnd($event)" [style.opacity]="cell.dragIndex === -1 ? 1 : i >= cell.dragIndex ? 0 : 1"

'

在這裡我一樣做了設定了 absoulate 及 [style.top]="i * 25 + 'px'",並且在一開始渲染時有達到想要的結果,只是我在拖曳之後,這兩個屬性就失效了,我實在想不明原因,請問你在開發時有遇過這個問題嗎?

不好意思打擾你了,這是我的信箱andynoway253@gmail.com,期待你的解答,這對我會有很大的幫助,感謝感謝!!!

starwilly commented 6 months ago

Hello @andynoway253 , 你有 repo 可以讓我試嗎?不過我很久沒寫 angular 了,所以不保證能幫上忙 🙈

andynoway253 commented 6 months ago

https://2019-f2e.vercel.app/FreeCell 這個是我目前的作品網站

然後 https://github.com/andynoway253/F2E/tree/master/frontend/src/app/2019/stage2 這個是我目前的code

請問這樣可以讓你做測試嗎?

starwilly @.***> 於 2024年1月10日 週三 下午11:18寫道:

Hello @andynoway253 https://github.com/andynoway253 , 你有 repo 可以讓我試嗎?不過我很久沒寫 angular 了,所以不保證能幫上忙 🙈

— Reply to this email directly, view it on GitHub https://github.com/starwilly/week2-free-cell/issues/39#issuecomment-1885046968, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEH47ZA4UPCOEY24TKYQY53YN2WNLAVCNFSM6AAAAABBJXZLDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGA2DMOJWHA . You are receiving this because you were mentioned.Message ID: @.***>

starwilly commented 5 months ago

我回覆在你的 repo~ https://github.com/andynoway253/F2E/issues/1