mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-11-16 01:38:21 +01:00
add support for drop custom event when drag is enable on an HTMLElement
All checks were successful
gitea-sync/antos/pipeline/head This commit looks good
All checks were successful
gitea-sync/antos/pipeline/head This commit looks good
This commit is contained in:
parent
cb744f31c1
commit
aa73eed074
4
d.ts/antos.d.ts
vendored
4
d.ts/antos.d.ts
vendored
@ -3633,13 +3633,13 @@ interface HTMLElement {
|
||||
* Enable the drag event dispatching on this
|
||||
* element
|
||||
*
|
||||
* This will trigger the `drag` event on the enabled
|
||||
* This will trigger the `dragging` and `drop` event on the enabled
|
||||
* on the element when the mouse is down, then move
|
||||
*
|
||||
* The event can be listened using the traditional way,
|
||||
* Example:
|
||||
* ```
|
||||
* elem.addEventListener('drag', (e) => { }, false);
|
||||
* elem.addEventListener('dragging', (e) => { }, false);
|
||||
* ```
|
||||
*
|
||||
* @meberof HTMLElement
|
||||
|
@ -54,13 +54,14 @@ interface HTMLElement {
|
||||
* Enable the drag event dispatching on this
|
||||
* element
|
||||
*
|
||||
* This will trigger the `dragging` event on the enabled
|
||||
* on the element when the mouse is down, then move
|
||||
* This will trigger the `dragging` and `drop` event on the enabled
|
||||
* element when the mouse is down, move, then up, then move
|
||||
*
|
||||
* The event can be listened using the traditional way,
|
||||
* Example:
|
||||
* ```
|
||||
* elem.addEventListener('dragging', (e) => { }, false);
|
||||
* elem.addEventListener('drop', (e) => { }, false);
|
||||
* ```
|
||||
*
|
||||
* @meberof HTMLElement
|
||||
@ -631,9 +632,16 @@ namespace OS {
|
||||
this.dispatchEvent(custom_event);
|
||||
};
|
||||
|
||||
var mouse_up = function (e: JQuery.MouseEventBase) {
|
||||
var mouse_up = (e: JQuery.MouseEventBase) => {
|
||||
$(window).off("pointermove", mouse_move);
|
||||
return $(window).off("pointerup", mouse_up);
|
||||
$(window).off("pointerup", mouse_up);
|
||||
// trigger the drop event
|
||||
const custom_event = new CustomEvent('drop', { detail:{
|
||||
origin: evt,
|
||||
current: e,
|
||||
offset: offset
|
||||
}});
|
||||
this.dispatchEvent(custom_event);
|
||||
};
|
||||
$(window).on("pointermove", mouse_move);
|
||||
$(window).on("pointerup", mouse_up);
|
||||
|
Loading…
Reference in New Issue
Block a user