MCPcopy
hub / github.com/pqina/filepond / create

Function create

src/js/app/view/item.js:36–142  ·  view source on GitHub ↗
({ root, props })

Source from the content-addressed store, hash-verified

34 * Creates the file view
35 */
36const create = ({ root, props }) => {
37 // select
38 root.ref.handleClick = e => root.dispatch('DID_ACTIVATE_ITEM', { id: props.id });
39
40 // set id
41 root.element.id = `filepond--item-${props.id}`;
42 root.element.addEventListener('click', root.ref.handleClick);
43
44 // file view
45 root.ref.container = root.appendChildView(root.createChildView(fileWrapper, { id: props.id }));
46
47 // file panel
48 root.ref.panel = root.appendChildView(root.createChildView(panel, { name: 'item-panel' }));
49
50 // default start height
51 root.ref.panel.height = null;
52
53 // by default not marked for removal
54 props.markedForRemoval = false;
55
56 // if not allowed to reorder file items, exit here
57 if (!root.query('GET_ALLOW_REORDER')) return;
58
59 // set to idle so shows grab cursor
60 root.element.dataset.dragState = 'idle';
61
62 const grab = e => {
63 if (!e.isPrimary) return;
64
65 let removedActivateListener = false;
66
67 const origin = {
68 x: e.pageX,
69 y: e.pageY,
70 };
71
72 props.dragOrigin = {
73 x: root.translateX,
74 y: root.translateY,
75 };
76
77 props.dragCenter = {
78 x: e.offsetX,
79 y: e.offsetY,
80 };
81
82 const dragState = createDragHelper(root.query('GET_ACTIVE_ITEMS'));
83
84 root.dispatch('DID_GRAB_ITEM', { id: props.id, dragState });
85
86 const drag = e => {
87 if (!e.isPrimary) return;
88
89 e.stopPropagation();
90 e.preventDefault();
91
92 props.dragOffset = {
93 x: e.pageX - origin.x,

Callers 9

setFiles.test.jsFile · 0.90
addFile.test.jsFile · 0.90
createPondFunction · 0.90
server.test.jsFile · 0.90
removeFile.test.jsFile · 0.90
setupPondFunction · 0.90
index.jsFile · 0.50
createViewFunction · 0.50

Calls

no outgoing calls

Tested by 2

createPondFunction · 0.72
setupPondFunction · 0.72