Blame view

public/assets/libs/Sortable/plugins/Swap/README.md 1.06 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  ## Swap Plugin
  This plugin modifies the behaviour of Sortable to allow for items to be swapped with eachother rather than sorted. Once dragging starts, the user can drag over other items and there will be no change in the elements. However, the item that the user drops on will be swapped with the originally dragged item.
  
  Demo: https://jsbin.com/yejehog/edit?html,js,output
  
  
  ---
  
  
  ### Mounting
  ```js
  import { Sortable, Swap } from 'sortablejs/modular/sortable.core.esm';
  
  Sortable.mount(new Swap());
  ```
  
  
  ---
  
  
  ### Options
  
  ```js
  new Sortable(el, {
  	swap: true, // Enable swap mode
  	swapClass: "sortable-swap-highlight" // Class name for swap item (if swap mode is enabled)
  });
  ```
  
  
  ---
  
  
  #### `swapClass` option
  Class name for the item to be swapped with, if swap mode is enabled. Defaults to `sortable-swap-highlight`.
  
  ```css
  .highlighted {
    background-color: #9AB6F1;
  }
  ```
  
  ```js
  Sortable.create(list, {
    swap: true,
    swapClass: "highlighted"
  });
  ```
  
  
  ---
  
  
  ### Event Properties
   - swapItem:`HTMLElement|undefined` — The element that the dragged element was swapped with