MCPcopy Index your code
hub / github.com/SortableJS/Sortable / dispatchEvent

Function dispatchEvent

src/EventDispatcher.js:5–57  ·  view source on GitHub ↗
(
	{
		sortable, rootEl, name,
		targetEl, cloneEl, toEl, fromEl,
		oldIndex, newIndex,
		oldDraggableIndex, newDraggableIndex,
		originalEvent, putSortable, extraEventProperties
	}
)

Source from the content-addressed store, hash-verified

3import PluginManager from './PluginManager.js';
4
5export default function dispatchEvent(
6 {
7 sortable, rootEl, name,
8 targetEl, cloneEl, toEl, fromEl,
9 oldIndex, newIndex,
10 oldDraggableIndex, newDraggableIndex,
11 originalEvent, putSortable, extraEventProperties
12 }
13) {
14 sortable = (sortable || (rootEl && rootEl[expando]));
15 if (!sortable) return;
16
17 let evt,
18 options = sortable.options,
19 onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
20 // Support for new CustomEvent feature
21 if (window.CustomEvent && !IE11OrLess && !Edge) {
22 evt = new CustomEvent(name, {
23 bubbles: true,
24 cancelable: true
25 });
26 } else {
27 evt = document.createEvent('Event');
28 evt.initEvent(name, true, true);
29 }
30
31 evt.to = toEl || rootEl;
32 evt.from = fromEl || rootEl;
33 evt.item = targetEl || rootEl;
34 evt.clone = cloneEl;
35
36 evt.oldIndex = oldIndex;
37 evt.newIndex = newIndex;
38
39 evt.oldDraggableIndex = oldDraggableIndex;
40 evt.newDraggableIndex = newDraggableIndex;
41
42 evt.originalEvent = originalEvent;
43 evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
44
45 let allEventProperties = { ...extraEventProperties, ...PluginManager.getEventProperties(name, sortable) };
46 for (let option in allEventProperties) {
47 evt[option] = allEventProperties[option];
48 }
49
50 if (rootEl) {
51 rootEl.dispatchEvent(evt);
52 }
53
54 if (options[onName]) {
55 options[onName].call(sortable, evt);
56 }
57}

Callers 1

_dispatchEventFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…