We can higlight the div with mouse movement, to draw a rectangular to select the items. and Drag and drop it to other folder or section.
- Lasso can be drawn on section
- Items under Lasso can be selected
- Selected Items can be dragged
- Selected Items can be dropped
- Selected Items Dragging Animation
- Better File Organization
- Testing
- Mouse Down to Higlight
- when mouseDown on item, that item will be selected.
- when mouseDown on
draggableArea
, the lasso will be appended. - when mouseDown on any other places, nothing will happended.
- How to store selected item
- when the item is being cover by Lasso,
highligted
class will be added. - These elements will be stored in
selectedItem
array. They will be used when these elements being dropped to thedroppable area
. By usingappendChild
- Beside that, These elements will also be cloned and store in
cloneSelectedItem
array, together with its original positon. It is used to perform the dragging animation. Noticed that when the selected elements is being drag, thecloneSelectedItem
will be following the cursor, whereby theselectedItem
will be staying where they are with an overlay.
- Draw a Lasso
- to draw a lasso, we need 2 points. Initial Cursor mouse down point (which i store in
click.initial
) and current mouse moving point. - second, you need to calculate if the mouse if moving to left or right, up or down.
- Lasso is just a normal div, that keep changing the attribute (top, left, height, and width) which can be calculated from the mouse cursor moving points
- Detroy Lasso
- Lasso will not be destroyed. When it is not being used. the width and height will be 0, and opacity is also 0. It is there, but we can't see.
- Custom Ghost Image on Dragging event
- Native Drag and Drop can only see single file image on dragging. To hide it, my plan is to create a hidden div to replace the image by
e.dataTransfer.setDragImage
. - and I will create another element (which can be anything or any style I want) just to follow the cursor when dragging.
- set the element to
position absolute
andtransform translate X and Y
it to the cursor point.
- Selected Items Animation to Cursor on Drag Start
- when the
cloneSelectedItems
are first cloned, they are being added to the DOM which is on the position of their original element. - It is like each
selectedItems
andcloneSelectedItems
are stacking together. - when the items is being dragged, all the
cloneSelectedItems
will be moving to cursor point bytranslate X and Y
- Animate Items back to original position when Dragging cancel
- when dragging process is cancel,
cloneSelectedItems
will be animated back to original position bytransform: translate(0px, 0px)
. - and when the mouseUp or dragEnd event, remove the element from DOM.
- I not sure if the way of faking dragImage is correct.
- Wrap the selected div into ghost-wrapper ? Then it will be easier to follow cursor during Ondrag event. I will just need to translate one element instead of multiple clonedItems
- Ghost Wrapper doesnt animate (transfrom: translate) with cursor.?
- Should I set Ghost Wrapper to fixed or absolute?