({ root, props })
| 34 | * Creates the file view |
| 35 | */ |
| 36 | const 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, |
no outgoing calls