005 Drag Ripple
帶避讓動態的拖曳排序
拖曳排序的游標、落點插入線和兩側元素的避讓動態,適用於清單、看板和橫向排列。
很多拖曳排序在拖動時其他元素不動,放開後清單才突然重排,落在了哪兩項之間,只能放開後再檢查。下面五條讓使用者在放開前就看到結果:
- 游標:所有可拖曳的元素都要設定。懸停時顯示手形,拖動時顯示抓取手形,使用者按下之前就知道它可以拖曳。
- 拖曳中的元素:跟隨指標,同時避開落點,不擋住插入線。橫向排列中向上浮起;縱向清單中移到一側,並縮小到約 90%。它原來的位置隨之合攏。
- 插入線:用來標出落點,是一條很淡的細線,顏色約為文字顏色的 15%;橫排時垂直,清單中水平;出現時從中間向兩端展開,落點改變時平移過去,元素原來的位置上不顯示。
- 避讓:插入線兩側的元素向外讓開,離得越近,讓得越多、動得越早:位移 = 10px × 0.7ⁿ,延遲 = 24ms × n,n 是與插入線相隔的元素數,緊鄰的為 0。圖示從 10px 起,卡片從 8px 起。
- 放下與取消:放開後,元素進入空位,其他元素以彈簧動態移到新位置;按 Esc 或在清單外放開視為取消,所有元素回到原位。
另外,只用 transform 移動元素,不改變版面;排序也要能用鍵盤完成;開啟「減少動態效果」時,只保留插入線。
參數
- 位移
- 圖示 10px;卡片 8px;每往外一個元素乘以 0.7
- 延遲
- 每往外一個元素增加 24ms
- 彈簧
- 幾乎沒有回彈;約 0.25s 停止
- 插入線
- 約為文字顏色的 15%
附帶的提示詞會沿用專案現有的拖曳邏輯,把這套效果加到你指定的清單、列和 Dock 上。
Make drag-to-reorder in my product feel like this. Apply it to the lists, rows and docks I name, and reuse any drag helper the project already has. 1. Cursor: a pointing hand over anything draggable, a grabbing hand while dragging. 2. Lift: the picked item follows the pointer, raised off the list so it never hides where it will land: above a horizontal row, or pulled aside and shrunk to about 90% in a vertical list. Its old slot closes up. 3. Drop hint: a faint, thin line in the gap where it will land (vertical in a row, horizontal in a list), about 15% of the text color. It grows from its middle when it appears and glides to each new gap. No line over the item's own slot. 4. Ripple: items on both sides of the line lean away from it. Counting n from the line (0 = the item touching it), item n moves A x 0.7^n (A is about 10px for icons, 8px for cards) and starts 24ms x n later, on a quick spring that barely overshoots and settles in about 0.25s. Nearer items move sooner and further, so the push spreads out like a ripple. 5. Drop: the item takes the gap and every item springs into its new place. Escape or dropping outside the list cancels, and everything springs back. 6. Give each motion its own curve (hand-like for the pointer, a small pop for the lift, springs for settling) instead of one ease-out everywhere. Move things with transforms, not layout. Let the keyboard reorder too, and with reduced motion keep only the line.





















