tiny-essentials 1.11.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/dist/node_modules/firebase-functions/lib/common/trace.cjs +82 -0
- package/dist/node_modules/firebase-functions/lib/logger/common.cjs +57 -0
- package/dist/node_modules/firebase-functions/lib/logger/index.cjs +158 -0
- package/dist/v1/TinyBasicsEs.js +1653 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.js +307 -0
- package/dist/v1/TinyDragDropDetector.min.js +1 -0
- package/dist/v1/TinyDragger.js +3668 -0
- package/dist/v1/TinyDragger.min.js +2 -0
- package/dist/v1/TinyDragger.min.js.LICENSE.txt +8 -0
- package/dist/v1/TinyEssentials.js +2888 -2
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.js +32 -0
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyToastNotify.js +24 -0
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +5340 -0
- package/dist/v1/TinyUploadClicker.min.js +2 -0
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +8 -0
- package/dist/v1/basics/fileManager.cjs +524 -0
- package/dist/v1/basics/fileManager.d.mts +209 -0
- package/dist/v1/basics/fileManager.mjs +443 -0
- package/dist/v1/basics/fullScreen.cjs +134 -0
- package/dist/v1/basics/fullScreen.d.mts +8 -0
- package/dist/v1/basics/fullScreen.mjs +121 -0
- package/dist/v1/basics/html.cjs +262 -0
- package/dist/v1/basics/html.d.mts +63 -0
- package/dist/v1/basics/html.mjs +208 -0
- package/dist/v1/basics/index.cjs +40 -0
- package/dist/v1/basics/index.d.mts +38 -1
- package/dist/v1/basics/index.mjs +4 -1
- package/dist/v1/build/TinyDragDropDetector.cjs +7 -0
- package/dist/v1/build/TinyDragDropDetector.d.mts +3 -0
- package/dist/v1/build/TinyDragDropDetector.mjs +2 -0
- package/dist/v1/build/TinyDragger.cjs +7 -0
- package/dist/v1/build/TinyDragger.d.mts +3 -0
- package/dist/v1/build/TinyDragger.mjs +2 -0
- package/dist/v1/build/TinyUploadClicker.cjs +7 -0
- package/dist/v1/build/TinyUploadClicker.d.mts +3 -0
- package/dist/v1/build/TinyUploadClicker.mjs +2 -0
- package/dist/v1/css/TinyDraggerExample.css +21 -0
- package/dist/v1/css/TinyDraggerExample.min.css +1 -0
- package/dist/v1/index.cjs +44 -0
- package/dist/v1/index.d.mts +40 -1
- package/dist/v1/index.mjs +6 -1
- package/dist/v1/libs/TinyDragDropDetector.cjs +268 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +123 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +228 -0
- package/dist/v1/libs/TinyDragger.cjs +906 -0
- package/dist/v1/libs/TinyDragger.d.mts +316 -0
- package/dist/v1/libs/TinyDragger.mjs +783 -0
- package/dist/v1/libs/TinyNotifyCenter.cjs +32 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +9 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +28 -0
- package/dist/v1/libs/TinyToastNotify.cjs +24 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +8 -0
- package/dist/v1/libs/TinyToastNotify.mjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +223 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +80 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +182 -0
- package/docs/v1/README.md +8 -2
- package/docs/v1/basics/fileManager.md +222 -0
- package/docs/v1/basics/fullScreen.md +183 -0
- package/docs/v1/basics/html.md +243 -0
- package/docs/v1/libs/TinyDragDropDetector.md +143 -0
- package/docs/v1/libs/TinyDragger.md +430 -0
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyNotifyCenter.md +20 -0
- package/docs/v1/libs/TinyToastNotify.md +19 -0
- package/docs/v1/libs/TinyUploadClicker.md +108 -0
- package/package.json +12 -2
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# 📥 TinyDragDropDetector
|
|
2
|
+
|
|
3
|
+
A lightweight JavaScript utility for detecting drag-and-drop file operations on a specific DOM element or the entire page. It manages the full drag lifecycle (`enter`, `over`, `leave`, `drop`) and provides hooks for handling UI changes or file uploads.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📦 Features
|
|
8
|
+
|
|
9
|
+
* Simple and lightweight.
|
|
10
|
+
* Full drag event lifecycle handling.
|
|
11
|
+
* CSS hover class management.
|
|
12
|
+
* Works on any DOM element or the entire page.
|
|
13
|
+
* Fully typed with JSDoc.
|
|
14
|
+
* Safe with robust error handling.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🔧 Usage Example
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import TinyDragDropDetector from './TinyDragDropDetector.js';
|
|
22
|
+
|
|
23
|
+
const dnd = new TinyDragDropDetector({
|
|
24
|
+
fullscreen: false,
|
|
25
|
+
target: document.getElementById('drop-area'),
|
|
26
|
+
hoverClass: 'hover-effect',
|
|
27
|
+
onDrop: (files, event) => {
|
|
28
|
+
console.log('Files dropped:', files);
|
|
29
|
+
},
|
|
30
|
+
onEnter: (event) => {
|
|
31
|
+
console.log('Drag entered');
|
|
32
|
+
},
|
|
33
|
+
onLeave: (event) => {
|
|
34
|
+
console.log('Drag left');
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Destroy when not needed
|
|
39
|
+
// dnd.destroy();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🔗 API Reference
|
|
45
|
+
|
|
46
|
+
### Class: `TinyDragDropDetector`
|
|
47
|
+
|
|
48
|
+
A drag-and-drop detector instance.
|
|
49
|
+
|
|
50
|
+
### Constructor
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
new TinyDragDropDetector(options)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Parameters:
|
|
57
|
+
|
|
58
|
+
| Name | Type | Default | Description |
|
|
59
|
+
| --------- | ------------------------------------------- | ------- | --------------------- |
|
|
60
|
+
| `options` | [`DragAndDropOptions`](#draganddropoptions) | `{}` | Configuration object. |
|
|
61
|
+
|
|
62
|
+
#### Throws:
|
|
63
|
+
|
|
64
|
+
* `TypeError` if `target` is not an `HTMLElement`.
|
|
65
|
+
* `TypeError` if `fullscreen` is not a boolean.
|
|
66
|
+
* `TypeError` if `hoverClass` is not a string.
|
|
67
|
+
* `TypeError` if `onDrop` is not a function.
|
|
68
|
+
* `TypeError` if `onEnter` is defined but not a function.
|
|
69
|
+
* `TypeError` if `onLeave` is defined but not a function.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### Instance Methods
|
|
74
|
+
|
|
75
|
+
| Method | Returns | Description |
|
|
76
|
+
| ----------------- | ------------- | ------------------------------------------------------------------------ |
|
|
77
|
+
| `getTarget()` | `HTMLElement` | Returns the DOM element where listeners are attached. |
|
|
78
|
+
| `getHoverClass()` | `string` | Returns the CSS class applied during drag hover. |
|
|
79
|
+
| `isFullScreen()` | `boolean` | Indicates whether the detector is in fullscreen mode (`document.body`). |
|
|
80
|
+
| `isDragging()` | `boolean` | Returns whether a drag operation is currently active over the target. |
|
|
81
|
+
| `bound()` | `boolean` | Returns whether the event listeners are currently bound to the target. |
|
|
82
|
+
| `destroy()` | `void` | Destroys the detector, unbinding all events and cleaning up CSS classes. |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🏗️ Event Callbacks
|
|
87
|
+
|
|
88
|
+
| Event | Signature | Description |
|
|
89
|
+
| --------- | --------------------------------------------- | ------------------------------------------- |
|
|
90
|
+
| `onDrop` | `(files: FileList, event: DragEvent) => void` | Fired when files are dropped. **Required**. |
|
|
91
|
+
| `onEnter` | `(event: DragEvent) => void` | Fired when dragging enters the target. |
|
|
92
|
+
| `onLeave` | `(event: DragEvent) => void` | Fired when dragging leaves the target. |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🛠️ DragAndDropOptions
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {Object} DragAndDropOptions
|
|
101
|
+
* @property {HTMLElement} [target=document.body] - The DOM element where drag listeners will be attached. Defaults to `document.body` if `fullscreen` is true or no target is provided.
|
|
102
|
+
* @property {boolean} [fullscreen=true] - If true, listeners are attached to the entire page (`document.body`). If false, the `target` must be specified.
|
|
103
|
+
* @property {string} [hoverClass="dnd-hover"] - CSS class applied to the target element while files are being dragged over it.
|
|
104
|
+
* @property {(files: FileList, event: DragEvent) => void} onDrop - Callback function executed when files are dropped onto the target.
|
|
105
|
+
* @property {(event: DragEvent) => void} [onEnter] - Optional callback triggered when dragging enters the target area.
|
|
106
|
+
* @property {(event: DragEvent) => void} [onLeave] - Optional callback triggered when dragging leaves the target area.
|
|
107
|
+
*/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## ⚠️ Warnings
|
|
113
|
+
|
|
114
|
+
* If `dataTransfer` is missing in a `dragover` or `drop` event, a console warning will be shown:
|
|
115
|
+
|
|
116
|
+
* `[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.`
|
|
117
|
+
* `[TinyDragDropDetector] [handleDrop] Drop event missing dataTransfer.`
|
|
118
|
+
|
|
119
|
+
This is a safe check to prevent runtime errors in malformed events.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🗑️ Cleanup
|
|
124
|
+
|
|
125
|
+
Call `destroy()` when the detector is no longer needed to prevent memory leaks:
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
dnd.destroy();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This unbinds all event listeners and removes the hover class if applied.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🎨 CSS Example
|
|
136
|
+
|
|
137
|
+
```css
|
|
138
|
+
/* Example hover effect */
|
|
139
|
+
.hover-effect {
|
|
140
|
+
outline: 3px dashed #4caf50;
|
|
141
|
+
background-color: rgba(76, 175, 80, 0.1);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# 🧲 TinyDragger
|
|
2
|
+
|
|
3
|
+
TinyDragger enables customizable **drag-and-drop** behavior for HTML elements.
|
|
4
|
+
It supports visual proxies, jail boundaries, collision detection, vibration feedback, drop restrictions, and custom events — all with a lightweight and flexible architecture.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 🖱️ Mouse & touch drag support
|
|
11
|
+
- 🔒 Jail constraints to restrict dragging area
|
|
12
|
+
- 💥 Collision detection with other elements
|
|
13
|
+
- 🔄 Auto-revert to original position
|
|
14
|
+
- 🎮 Vibration feedback via `navigator.vibrate()`
|
|
15
|
+
- 👻 Visual clone during drag (proxy)
|
|
16
|
+
- 🎨 Fully configurable class names
|
|
17
|
+
- 📦 Clean destroy method with memory-safe teardown
|
|
18
|
+
- 🔔 Custom drag and drop events
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 Installation
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import TinyDragger from './TinyDragger.js';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🧰 Constructor
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
new TinyDragger(targetElement, options?)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Parameters:
|
|
37
|
+
|
|
38
|
+
| Name | Type | Default | Description |
|
|
39
|
+
| --------------- | ------------- | ------------ | --------------------------------- |
|
|
40
|
+
| `targetElement` | `HTMLElement` | **required** | The element to enable dragging on |
|
|
41
|
+
| `options` | `Object` | `{}` | Optional configuration |
|
|
42
|
+
|
|
43
|
+
### Options:
|
|
44
|
+
|
|
45
|
+
| Option | Type | Default | Description |
|
|
46
|
+
| ----------------------- | ------------------------------ | ---------------------- | -------------------------------------------------------- |
|
|
47
|
+
| `jail` | `HTMLElement` | `null` | Optional container that restricts movement |
|
|
48
|
+
| `collisionByMouse` | `boolean` | `false` | Use mouse position instead of bounding box for collision |
|
|
49
|
+
| `classDragging` | `string` | `'dragging'` | Class applied to the clone element |
|
|
50
|
+
| `classBodyDragging` | `string` | `'drag-active'` | Class applied to the `<body>` during dragging |
|
|
51
|
+
| `classJailDragging` | `string` | `'jail-drag-active'` | Class applied to jail while dragging |
|
|
52
|
+
| `classJailDragDisabled` | `string` | `'jail-drag-disabled'` | Class applied to jail when dragging is disabled |
|
|
53
|
+
| `classDragCollision` | `string` | `'dragging-collision'` | Class applied to elements when collision is detected |
|
|
54
|
+
| `classHidden` | `string` | `'drag-hidden'` | Class used to hide the original element while dragging |
|
|
55
|
+
| `lockInsideJail` | `boolean` | `false` | Prevent drag from exceeding jail bounds |
|
|
56
|
+
| `dropInJailOnly` | `boolean` | `false` | Prevent drop outside the jail area |
|
|
57
|
+
| `multiCollision` | `boolean` | `false` | Enables returning multiple collided elements |
|
|
58
|
+
| `vibration` | `VibrationPatterns` or `false` | `false` | Vibration feedback configuration |
|
|
59
|
+
| `revertOnDrop` | `boolean` | `false` | Return to original position after dropping |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 📳 Vibration Patterns
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
type VibrationPatterns = {
|
|
67
|
+
start: number[] | false,
|
|
68
|
+
end: number[] | false,
|
|
69
|
+
collide: number[] | false,
|
|
70
|
+
move: number[] | false
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 📚 Public Methods
|
|
77
|
+
|
|
78
|
+
### `enable()`
|
|
79
|
+
|
|
80
|
+
🔓 Re-enables dragging after being disabled.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### `disable()`
|
|
85
|
+
|
|
86
|
+
🚫 Temporarily disables dragging. Still allows re-enabling later.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### `destroy()`
|
|
91
|
+
|
|
92
|
+
💣 Fully disables the instance, removes event listeners, and clears any DOM state.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### `addCollidable(element: HTMLElement)`
|
|
97
|
+
|
|
98
|
+
➕ Adds an element to the collision tracking list.
|
|
99
|
+
🛑 Throws if the element is not a valid `HTMLElement`.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### `removeCollidable(element: HTMLElement)`
|
|
104
|
+
|
|
105
|
+
➖ Removes an element from the collision list.
|
|
106
|
+
🛑 Throws if the element is not a valid `HTMLElement`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `setVibrationPattern({ startPattern, endPattern, collidePattern, movePattern })`
|
|
111
|
+
|
|
112
|
+
📳 Updates the vibration patterns used during drag events.
|
|
113
|
+
Each pattern must be either `false` or an array of numbers.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
### `disableVibration()`
|
|
118
|
+
|
|
119
|
+
🔕 Turns off all vibration feedback.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### `getOffset(event: MouseEvent | Touch): { x: number, y: number }`
|
|
124
|
+
|
|
125
|
+
📐 Returns the X and Y offset from the event to the top-left corner of the element.
|
|
126
|
+
🛑 Throws if the event is invalid.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### `getCollidedElementByRect(rect: DOMRect): HTMLElement | null`
|
|
131
|
+
|
|
132
|
+
🎯 Detects if a `DOMRect` collides with any registered collidable elements.
|
|
133
|
+
🛑 Throws if the rect is invalid.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### `getAllCollidedElementsByRect(rect: DOMRect): HTMLElement[]`
|
|
138
|
+
|
|
139
|
+
📌 Returns **all elements** currently intersecting the given rectangle. Useful for detecting multiple overlaps when dragging.
|
|
140
|
+
🛑 Throws if `rect` is not a valid `DOMRect` with numeric `left`, `right`, `top`, and `bottom` properties.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### `getCollidedElement(x: number, y: number): HTMLElement | null`
|
|
145
|
+
|
|
146
|
+
📌 Detects if the given screen coordinates collide with any tracked element.
|
|
147
|
+
🛑 Throws if `x` or `y` is not a number.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### `getAllCollidedElements(x: number, y: number): HTMLElement[]`
|
|
152
|
+
|
|
153
|
+
📌 Detects **all elements** currently under the given screen coordinates. Works well when `collisionByMouse` is enabled.
|
|
154
|
+
🛑 Throws if `x` or `y` is not a number.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### `getDragging(): boolean`
|
|
159
|
+
|
|
160
|
+
🔄 Returns whether dragging is currently active.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### `getLockInsideJail(): boolean`
|
|
165
|
+
|
|
166
|
+
🔒 Returns whether movement is restricted inside the jail container.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### `setLockInsideJail(value: boolean): void`
|
|
171
|
+
|
|
172
|
+
⚙️ Sets whether movement is restricted inside the jail container.
|
|
173
|
+
🛑 Throws if `value` is not a boolean.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### `getRevertOnDrop(): boolean`
|
|
178
|
+
|
|
179
|
+
↩️ Returns whether the element should revert to its original position on drop.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### `setRevertOnDrop(value: boolean): void`
|
|
184
|
+
|
|
185
|
+
⚙️ Sets whether the element should revert to its original position on drop.
|
|
186
|
+
🛑 Throws if `value` is not a boolean.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### `getCollisionByMouse(): boolean`
|
|
191
|
+
|
|
192
|
+
🖱️ Returns whether collision detection uses mouse position instead of element bounding rectangles.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### `setCollisionByMouse(value: boolean): void`
|
|
197
|
+
|
|
198
|
+
⚙️ Sets whether collision detection uses mouse position instead of element bounding rectangles.
|
|
199
|
+
🛑 Throws if `value` is not a boolean.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### `getDropInJailOnly(): boolean`
|
|
204
|
+
|
|
205
|
+
🚫 Returns whether dropping is restricted inside the jail container.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### `setDropInJailOnly(value: boolean): void`
|
|
210
|
+
|
|
211
|
+
⚙️ Sets whether dropping is restricted inside the jail container.
|
|
212
|
+
🛑 Throws if `value` is not a boolean.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### `checkDragCollision(event: MouseEvent | Touch): void`
|
|
217
|
+
|
|
218
|
+
🎯 Checks for collision between the drag proxy and registered elements.
|
|
219
|
+
💥 Applies or removes the collision class depending on overlap.
|
|
220
|
+
📳 Triggers vibration if configured.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### `execCollision(event: MouseEvent | Touch): { inJail: boolean; collidedElement: HTMLElement | null }`
|
|
225
|
+
|
|
226
|
+
🧩 Executes collision detection logic based on the drag position and mode.
|
|
227
|
+
📍 Uses either the mouse point or the proxy rectangle depending on `collisionByMouse`.
|
|
228
|
+
🔒 Respects `dropInJailOnly` and jail boundaries.
|
|
229
|
+
🛑 Returns `{ inJail: false, collidedElement: null }` if dragging is not active.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### `getTarget(): HTMLElement`
|
|
234
|
+
|
|
235
|
+
🎯 Returns the original element being dragged.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### `getJail(): HTMLElement | null`
|
|
240
|
+
|
|
241
|
+
🚧 Returns the jail container element if one is set.
|
|
242
|
+
Returns `null` if no jail is configured.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### `getDragProxy(): HTMLElement | null`
|
|
247
|
+
|
|
248
|
+
👻 Returns the current proxy (clone) element being dragged.
|
|
249
|
+
Returns `null` if no proxy is active.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### `getLastCollision(): HTMLElement | null`
|
|
254
|
+
|
|
255
|
+
💥 Returns the last collided element (if any).
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### `getCollidables(): HTMLElement[]`
|
|
260
|
+
|
|
261
|
+
🧲 Returns the list of elements that are considered for collision detection.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### `getDragHiddenClass(): string`
|
|
266
|
+
|
|
267
|
+
👀 Returns the CSS class used to hide the original element during dragging.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### `getClassDragging(): string`
|
|
272
|
+
|
|
273
|
+
🎬 Returns the CSS class applied to the clone while it is being dragged.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### `getClassBodyDragging(): string`
|
|
278
|
+
|
|
279
|
+
🧍 Returns the CSS class applied to `<body>` when dragging is active.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### `getClassJailDragging(): string`
|
|
284
|
+
|
|
285
|
+
🏗️ Returns the CSS class applied to the jail element while dragging is active.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
### `getClassJailDragDisabled(): string`
|
|
290
|
+
|
|
291
|
+
🚫 Returns the CSS class applied to the jail when dragging is disabled.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### `getClassDragCollision(): string`
|
|
296
|
+
|
|
297
|
+
⚠️ Returns the CSS class applied to elements when a collision is detected.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
### `getVibrations(): { start: number[] | false, end: number[] | false, collide: number[] | false, move: number[] | false }`
|
|
302
|
+
|
|
303
|
+
🎵 Returns the full vibration pattern configuration used during dragging.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
### `getStartVibration(): number[] | false`
|
|
308
|
+
|
|
309
|
+
📳 Returns the vibration pattern used at the **start** of a drag.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
### `getEndVibration(): number[] | false`
|
|
314
|
+
|
|
315
|
+
📴 Returns the vibration pattern used at the **end** of a drag.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
### `getCollideVibration(): number[] | false`
|
|
320
|
+
|
|
321
|
+
🎯 Returns the vibration pattern used when **colliding** with another element.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### `getMoveVibration(): number[] | false`
|
|
326
|
+
|
|
327
|
+
🚶 Returns the vibration pattern used during **movement** while dragging.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
### `isEnabled(): boolean`
|
|
332
|
+
|
|
333
|
+
✅ Returns whether the drag-and-drop functionality is currently enabled.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## 🔁 Events
|
|
338
|
+
|
|
339
|
+
The target element will emit these events:
|
|
340
|
+
|
|
341
|
+
| Event | Description |
|
|
342
|
+
| ---------- | ------------------------------------------------ |
|
|
343
|
+
| `drag` | Fired at the beginning of a drag |
|
|
344
|
+
| `dragging` | Continuously fired while dragging |
|
|
345
|
+
| `drop` | Fired at the end of the drag with collision info |
|
|
346
|
+
|
|
347
|
+
### Example:
|
|
348
|
+
|
|
349
|
+
```js
|
|
350
|
+
targetEl.addEventListener('drop', (e) => {
|
|
351
|
+
console.log('Dropped on:', e.detail.target);
|
|
352
|
+
});
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## 🛡️ Error Handling
|
|
358
|
+
|
|
359
|
+
* Throws errors if the constructor options are of invalid types.
|
|
360
|
+
* Throws if using destroyed instances (`destroy()` has been called).
|
|
361
|
+
* Throws on invalid usage of methods like `addCollidable` or `getOffset`.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## ✅ Example
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
const box = document.getElementById('draggableBox');
|
|
369
|
+
const jail = document.getElementById('jailContainer');
|
|
370
|
+
|
|
371
|
+
const dragger = new TinyDragger(box, {
|
|
372
|
+
jail,
|
|
373
|
+
lockInsideJail: false,
|
|
374
|
+
collisionByMouse: false,
|
|
375
|
+
revertOnDrop: false,
|
|
376
|
+
vibration: {
|
|
377
|
+
start: [30],
|
|
378
|
+
move: [5],
|
|
379
|
+
collide: [80],
|
|
380
|
+
end: [20, 10, 20],
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
const dropTarget = document.getElementById('dropArea');
|
|
385
|
+
dragger.addCollidable(dropTarget);
|
|
386
|
+
|
|
387
|
+
box.addEventListener('drop', (e) => {
|
|
388
|
+
if (e.detail.target === dropTarget) {
|
|
389
|
+
alert('Dropped successfully!');
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## 🧼 Clean-Up
|
|
397
|
+
|
|
398
|
+
Call `.destroy()` to completely remove drag behavior and all event listeners:
|
|
399
|
+
|
|
400
|
+
```js
|
|
401
|
+
dragger.destroy();
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 🧪 Testing & Styling
|
|
407
|
+
|
|
408
|
+
* 🎨 **Example Stylesheets:**
|
|
409
|
+
You can find optional example styles to get started or test layout integration in:
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
dist/v1/css/TinyDraggerExample.css
|
|
413
|
+
dist/v1/css/TinyDraggerExample.min.css
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
* 🧱 **Test Environment:**
|
|
417
|
+
A ready-to-use HTML test page is available at:
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
test/html/TinyDragger
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
This includes practical demos and scenarios to test dragging, collision, jail constraints, and more.
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## 🧠 Notes
|
|
428
|
+
|
|
429
|
+
* Touch support uses the first touch point only.
|
|
430
|
+
* Make sure your draggable element has `position: relative` or `absolute` if it’s meant to be positioned manually after drop.
|
|
@@ -274,6 +274,26 @@ You create a rich notification element dynamically, with optional avatar, title,
|
|
|
274
274
|
|
|
275
275
|
---
|
|
276
276
|
|
|
277
|
+
## 🔥 `destroy()`
|
|
278
|
+
|
|
279
|
+
Destroys the current **TinyNotifyCenter** instance.
|
|
280
|
+
It **removes all event listeners**, **clears all notifications**, and **optionally removes the entire notification center template from the DOM**.
|
|
281
|
+
|
|
282
|
+
### Syntax
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
tinyNotifyCenter.destroy();
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Behavior
|
|
289
|
+
|
|
290
|
+
* Removes all event listeners (`click`, `close`, `clear all`, overlay clicks).
|
|
291
|
+
* Clears all notifications from the list.
|
|
292
|
+
* Removes the UI (`.notify-overlay`, `.notify-bell`, etc.) from the DOM.
|
|
293
|
+
* Cleans internal references (`center`, `list`, `button`, `overlay`, `badge`, `modes`).
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
277
297
|
## 🎨 CSS Files Location
|
|
278
298
|
|
|
279
299
|
The CSS files for the TinyNotify project build can be found in the following folder:
|
|
@@ -273,6 +273,25 @@ Displays a notification with customizable content and duration based on message
|
|
|
273
273
|
|
|
274
274
|
---
|
|
275
275
|
|
|
276
|
+
## 🔥 `destroy()`
|
|
277
|
+
|
|
278
|
+
Destroys the current **TinyToastNotify** instance.
|
|
279
|
+
It **removes the notification container from the DOM** and **clears all pending notifications**. This method is useful when the notification system is no longer needed or when changing views in a single-page application.
|
|
280
|
+
|
|
281
|
+
### Syntax
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
tinyToastNotify.destroy();
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Behavior
|
|
288
|
+
|
|
289
|
+
* Removes the entire container (`.notify-container`) from the DOM.
|
|
290
|
+
* Automatically cancels any pending or visible toasts.
|
|
291
|
+
* Cleans up internal references.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
276
295
|
## 🎨 CSS Files Location
|
|
277
296
|
|
|
278
297
|
The CSS files for the TinyNotify project build can be found in the following folder:
|