How can I select multiple items inside an iron-selector
by clicking, holding and dragging the mouse, or even by drawing a rectangle with the mouse, and selecting all the items under it?
I use Polymer 1.11.3 and iron-selector 2.1.0, and reading the documentation provided no obvious solution.
This is my actual element in which I want to enable the drag-selection:
My goal is to be able to click e.g. on Sunday 7, drag the mouse to 15, release the click, and have 7-15 selected.
To be able to select my mouse click and drag, do the following:
Set the css property
user-select: none;
to the element which holds your selectable items.Add
on-track="handleTrack"
to the element which holds your selectable items.Put this div somewhere in your element:
<div id="selectionBox" style="position:absolute; top:0; left:0; height:0; width:0; border:2px solid #000; background-color:rgba(128, 128, 128, 0.3); z-index:999;"></div>
Then, add these functions to your element:
This code also works if you have multiple
iron-selector
.