@@ -75,6 +75,9 @@ Removes containers from this draggable instance.
75
75
** ` draggable.getClassNameFor(name: String): String ` **
76
76
Returns class name for class identifier, check the classes table below for identifiers.
77
77
78
+ ** ` draggable.getClassNamesFor(name: String): String[] ` **
79
+ Returns array of class name for class identifier, useful when working with atomic css, check the classes table below for identifiers.
80
+
78
81
** ` draggable.isDragging(): Boolean ` **
79
82
Returns true or false, depending on this draggables dragging state.
80
83
@@ -117,9 +120,11 @@ plugins controls the mirror movement. Default: `[]`
117
120
Sensors dictate how drag operations get triggered, by listening to native browser events.
118
121
By default draggable includes the ` MouseSensor ` & ` TouchSensor ` . Default: ` [] `
119
122
120
- ** ` classes {Object } ` **
123
+ ** ` classes {{String: String|String[]} } ` **
121
124
Draggable adds classes to elements to indicate state. These classes can be used to add styling
122
- on elements in certain states.
125
+ on elements in certain states. Accept String or Array of strings.
126
+
127
+ ** NOTE** : When specifying multiple classes to an indicate state, the first class MUST be unique for that state to avoid duplicate classes for other states.
123
128
124
129
** ` exclude {plugins: Plugin[], sensors: Sensor[]} ` **
125
130
Allow excluding default plugins and default sensors. Use with caution as it may create strange behavior.
@@ -156,15 +161,15 @@ Allow excluding default plugins and default sensors. Use with caution as it may
156
161
157
162
| Name | Description | Default |
158
163
| -------------------- | ------------------------------------------------------------------- | ---------------------------------- |
159
- | ` body:dragging ` | Class added on the document body while dragging | ` draggable--is-dragging ` |
160
- | ` container:dragging ` | Class added on the container where the draggable was picked up from | ` draggable-container--is-dragging ` |
161
- | ` source:dragging ` | Class added on the draggable element that has been picked up | ` draggable-source--is-dragging ` |
162
- | ` source:placed ` | Class added on the draggable element on ` drag:stop ` | ` draggable-source--placed ` |
163
- | ` container:placed ` | Class added on the draggable container element on ` drag:stop ` | ` draggable-container--placed ` |
164
- | ` draggable:over ` | Class added on draggable element you are dragging over | ` draggable--over ` |
165
- | ` container:over ` | Class added on draggable container element you are dragging over | ` draggable-container--over ` |
166
- | ` source:original ` | Class added on the original source element, which is hidden on drag | ` draggable--original ` |
167
- | ` mirror ` | Class added on the mirror element | ` draggable-mirror ` |
164
+ | ` body:dragging ` | Classes added on the document body while dragging | ` draggable--is-dragging ` |
165
+ | ` container:dragging ` | Classes added on the container where the draggable was picked up from | ` draggable-container--is-dragging ` |
166
+ | ` source:dragging ` | Classes added on the draggable element that has been picked up | ` draggable-source--is-dragging ` |
167
+ | ` source:placed ` | Classes added on the draggable element on ` drag:stop ` | ` draggable-source--placed ` |
168
+ | ` container:placed ` | Classes added on the draggable container element on ` drag:stop ` | ` draggable-container--placed ` |
169
+ | ` draggable:over ` | Classes added on draggable element you are dragging over | ` draggable--over ` |
170
+ | ` container:over ` | Classes added on draggable container element you are dragging over | ` draggable-container--over ` |
171
+ | ` source:original ` | Classes added on the original source element, which is hidden on drag | ` draggable--original ` |
172
+ | ` mirror ` | Classes added on the mirror element | ` draggable-mirror ` |
168
173
169
174
### Example
170
175
@@ -195,3 +200,16 @@ const draggable = new Draggable(document.querySelectorAll('ul'), {
195
200
}
196
201
});
197
202
```
203
+
204
+ Create draggable with specific classes:
205
+
206
+ ``` js
207
+ import { Draggable } from ' @shopify/draggable' ;
208
+
209
+ const draggable = new Draggable (document .querySelectorAll (' ul' ), {
210
+ draggable: ' li' ,
211
+ classes: {
212
+ ' draggable:over' : [' draggable--over' , ' .bg-red-200' , ' bg-opacity-25' ],
213
+ },
214
+ });
215
+ ```
0 commit comments