daybrush / selecto Goto Github PK
View Code? Open in Web Editor NEWSelecto.js is a component that allows you to select elements in the drag area using the mouse or touch.
Home Page: https://daybrush.com/selecto
License: MIT License
Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.
Home Page: https://daybrush.com/selecto
License: MIT License
There a lot of types are not visible to typescript when using ngx-moveable as they are not part of the public api.
The fix is to copy the declarations folder from react-moveable to ngx-moveable, and to append export * from './declaration/types';
to the end of public-api.d.ts
. This worked for me locally.
A workaround is to import the types from react-moveable directly:
import { OnDrag, OnDragEnd, OnDragGroup, OnDragGroupEnd, OnDragGroupStart, OnDragStart } from 'react-moveable/declaration/types';
but this is kind of hacky.
When the parent container contains css style: "transform:'scale(1)'", the selection box position is incorrect.
The reason for the error: the start and end positions of the selected rectangle have not been converted.
Hey, thanky for providing such a great tool! I want to use selecto with moveable. Moveable is working but selecto is not, when I'm importing it in my .js it says "Interface cannot be instantiated". I had this issue with moveable too, and it was kindly fixed. It would be great if this would be possible with selecto too, so I can use them together.
Thanks a lot!
May I know is this possible to use selecto to select desired target using code instead of mouse click on the target object?
I am trying to achieve something like click one single target object (target1) to also select other target object (target2) programmatically that are grouped.
For example:
<div class="moveable target" id="target1">target 1 under group 1</div>
<div class="moveable target" id="target2">target 2 under group 1</div>
const selecto = new Selecto({
container: document.body,
selectableTargets: [".target"],
hitRate: 80,
selectByClick: true,
selectFromInside: false,
continueSelect: false,
boundContainer: true,
toggleContinueSelect: ["shift"],
ratio: 0,
});
Am using Selecto to select table rows and has been working good. One problem I notice when using Ctrl and/or shift toggleContinueSelect
is that when moving away from the page using Ctrl+Tab and returning back makes Selecto think that I keep pressing Ctrl/shift and it continues to select without removing old selection.
Reproduction steps to follow on above page (or in your demo page):
Notice that I never intended to use Ctrl for selection at all.
Before selected one target, can fire hover event target?
Thank @daybrush!
What does e.added and .classList stand for and how can I store all selected <div>
s to my own variable const divsSelected=
...that's confusing to me.
a selectEnd event can't have a drag start? makes no sense.
i have spent a grate amount of time now trying to have a draggable element and also using selecto at the same time and finally got it the way i wanted. was something about live select and select on end mixing that made some bad behaviors.
it was buggy for a while. I simply just clicked an element without dragging and the isDragStart
was still saying that it was true while i haven't even moved the mouse one bit.
But also it seems you don't use the native drag and drop event
looking at the evt.inputEvent.type
after selectEnd indicates that the event is of type mousedown
event (based on this assumption it seems like you are trying to emulate some of the drag events using only mousedown+mousemove+mouseup events?)
wouldn't it benefit if you used native dragstart
, dragend
and drag
event instead? and used some elm.draggable
properties instead? i could not find them in the registered event listener anywhere in the chrome inspector
When dragging the select area the area starts in the wrong spot, offset by top and left, often to the right and below the original area. The dragContainer is being resized after the component mounts which is potentially/likely causing the issue, though. Additionally, there is a transform: scale on the dragContainer.
There doesn't appear to method to update/recalculate the dragContainer bounding rect. Ideas on how to fix this?
after selection of svgs and span elements by react-selecto and make group elements with react-moveable , when select those group elements for few svgs they're not able to selected as a group.
ngx-selecto
Hi, when I position the selecto container in the middle of a page using a transform. The drag selection drag box is positioned in the wrong place.
I centered the container like this. If I remove the transform, it all works fine.
.container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; }
If this isn't easy to fix, is it possible to hide the drag area during the selection process?
Is there has a prop like disable
to disable Selecto
?
except
{
disabled ? <Selecto /> : null
}
Cannot install selecto in angular 11.2.3
diandiantu on master is 📦 v0.0.0
➜ npm install ngx-selecto
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"^11.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^8.2.14" from [email protected]
npm ERR! node_modules/ngx-selecto
npm ERR! ngx-selecto@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
Similar to explorer press shift key.
Hi! Thanks for the awesome library!
I would like to ask about the selecto detection when the item is transformed, such as "rotated". This is the example I see from moveable demo:
As you can see, the element bound is rotated, but the selecto still detect it as selected.
Should selecto also able to detect the item bound when it's rotated?
Thanks!
There is a console.log
statement in the svelte-selecto
package, its not possible for me to disable this in production because it's not wrapped in a conditional. Ideally developer logs shouldn't be visible in production.
Hi, when selecto container is placed in parent which already is transformed then selection drag area is positioned incorrectly. I have attached modified example to reproduce this behaviour.
Of cource as workaround I can hide drag area but I would like to have it in right place.
Thanks in advance.
After making the elements in form of group and rotating that group make inner elements rotate too and outter moveable selection boundaries also change...
Hello, there's anyway to use window scroll as an option ? Without using a container to get her ref.
I've tried to follow the docs but i didn't succeed using window.scroll
I am trying to write some acceptance tests around Selecto, and I was wondering if anyone has any good testing strategies. Basically, I want to test that when I select a region, a modal appears with the appropriate data (see screencap below). Ember has pretty good test helpers to allow triggering events, for example you could write a helper for drag and drop:
export async function dragAndDrop(fieldSelector, dropZoneSelector, options) {
await triggerEvent(fieldSelector, 'mousedown');
await triggerEvent(fieldSelector, 'dragstart', options);
await triggerEvent(dropZoneSelector, 'dragenter', options);
await triggerEvent(dropZoneSelector, 'drop', options);
}
I've tried something similar to simulate selecting a region, but haven't found what events I need to trigger to do that. OR if anyone has suggestions on how to hook into Selecto's event directly, that would be appreciated.
When I set selectByClick
to false, the item still could be selected by single click, but when I set selectFromInside
to false, it works,but another problem occurs: I can not selected item from inside...It makes me confused, as you can see in your demo...
I have been trying to use selecto to select rows in the table. I want to allow selection of rows using keyboard and also using mouse. I take care of keyboard selection and selecto is used only for mouse selection. Whenever keyboard is used, I use selecto.setSelectedTargets to set the current selection and it works fine so far.
This particular problem arises only when mixing keyboard and mouse. Follow below steps on above sample page that is created to reproduce this issue. I have used textbox instead of up or down arrow key because I started with textbox first. I can rewrite to use keyboard event if needed or simplify reproduction sample.
Callbacks are called with removed containing previously selected elements even though Shift (toggle) key is still pressed.
Am not sure whether this is a bug or I need to set keyContainer option with different value. Please advice.
Thank you for building such a nice library.
I have one question. I want to style the area created from the mouse cursor when dragging.
But I have no idea what the class of this is. Even when I look through the code of this library, I couldn't find the part that sets its style. How do I modify CSS to change its style?
Hello I was wondering if you could provide examples of Selecto together with Moveable (especially resizable). Thank you for all your great work.
I am always grateful for the projects you create.
I thought about the moveable demo site, but is it possible to fix the aspect ratio of range selection?
For example, if you hold down the Shift key and it becomes a square, you will find many useful scenes.
I am happy if it becomes a good suggestion.
I'm using selecto to trigger an event when an area on a timeline is selected. There is a separate event that is triggered when the timeline is clicked. I am using on:selectEnd
to trigger the event, however, the selectEnd
event is triggered even if the target is merely clicked resulting in an event.detail.rect
with exactly the same value for left
and right
. This presents a problem for me, because the selectEnd
event is triggered when a click
event is also triggered.
Suggestion: It would be great if there was a prop called minimumPixelsForSelection
that allows me to specify that a 'selection' is only 'active' after a certain number of pixels have been selected. This wouldn't change the display of the blue selection box, just prevent the selectionEnd
event being triggered when a target is clicked.
EDIT: For clarity, selectEnd
is fired regardless of whether select
event is fired. Hence why changing the hitRate
value doesn't fix this issue.
EDIT: Closing because I think this is actually a non-issue. I can just fire my event conditionally based on the difference between the two numbers. The only downside is that the selection logic is running on every click, but there is no noticeable performance hit so not an issue.
Hello again @daybrush , Thank you so mush for great plugin. I'm using react-moveable with selecto as [https://daybrush.com/selecto/storybook/?path=/story/selecto-with-moveable--select-moveable-targets-in-real-time].
In your example, selection is unselect by clicking within this ".selecto-area .elements"
div.
I would like to remove selection by clicking outside area of Selecto.
I tried with two option,
First option with setTargets([])
to remove selection and it was remove the selection but i can't select items again.
Second option is i add ".selecto-area .elements"
class to body tag. But other click event doesn't work inside that body.
Do you have any example like that please?
In all examples (in code sandbox) an error is thrown when you click in a selectable area. this occurs only for svelte-selecto (and lit). For the other packages. Tested on Chrome and Firefox (latest stable - win 10).
Is it possible to only start selection only when clicking on the actual background container, not on the objects themselves? I'm using selecto (without moveable) and when I click to drag an element selecto also starts selecting. I tried selectFromInside: false
, but there was no effect.
Firstly, thank you for this library. I am using react-window.
Selecto runs querySelectorAll method for selectableTargets only during onDragStart.
For windowing, is it possible re-find selectableTargets during onDrag ?
Could a more logical piece of code be written for this use ?
Would it be possible to add a prop to selecto like limitDragArea
so that after a drag has started inside the dragContainer
, then the selecting area cannot go outside of the dragContainer
? Currently, you can't start a select outside a dragContainer
(which is great) but you can start a select inside a dragContainer
and then drag outside of that container. This prop would essentially limit the bounds to the bounds of the dragContainer
specified
When i double click the element, onSelectEnd is triggered only once and isDouble is false(expectation is true).
When i double click the blank space, onSelectEnd is triggered twice. IsDouble is false in first event and it is true in second event.
I checked the inputEvent type is 'mousedown'. Does‘t meet the following conditions.
if (inputEvent && inputEvent.type !== "mousedown" && inputEvent.type !== "touchstart") {
this.trigger("dragEnd", {
isDouble: false,
isDrag: false,
...e,
rect,
});
}
npm ERR! code ETARGET
npm ERR! notarget No matching version found for selecto@^1.10.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'vue-selecto'
npm ERR! notarget
I got this error message: [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
@daybrush Can you add a parameter? like
1、event: "drag" or "click"
or
2、isClick: true or false
I'm using React-selecto
I created a moveable component that having text. Using selecto, it can be selected on a single click. I need it to be editable on a double click. Is it possible through your library?
Is there a way to start selection only on keypress?
For example, I want to start selecting only when I have the ctrl key pressed, not all the time.
Text inputs do not get a onBlur event anymore, and focus does not move away.
Please see this demo: https://codesandbox.io/s/cool-roentgen-6u4ib
I have an editor with textfields around a canvas, when a user changes a text in the textfield and then starts a selection, the blur is not triggered, meaning I don't know that I should save the textlayer.
Also, the focus stays on menus that should not have focus after clicking on the canvas.
Codesandbox: https://codesandbox.io/s/nervous-sound-2cb4j?file=/src/App.js:239-240
Demo: https://share.getcloudapp.com/Jru4qmjp
Is there any support for supporting virtualized list?
On scroll using scrollOptions the selection portion is going above the bound area vertically.
How is this possible as my code does not accept HTMLElement as return.
after selecting group elements and start dragging all elements collapse on same position but if i start scalling after selecting elements than selected elements don't collapse then dragging also work perfectly.
I need table rows to be selected and trying to achieve that using selecto. Attached a sample code that I have been trying and my intention is I should be able to select the rows by clicking them individually (which works) and also by dragging mouse over TRs, which I dont know how to achieve. Can someone help me to achieve it?
After upgrading react-selecto from v1.7.4 to v1.9.2 the mouse down and drag no longer works when moving an element with react-moveable, unless you explicitly click (mouse down & up) and then drag. This behaviour can be reproduced in the example: https://daybrush.com/selecto/storybook/?path=/story/selecto-with-moveable--select-moveable-targets-in-real-time
Observed behaviour (mouse is held down, but the element does not move):
As a side note, it would be good to couple the exact version of selecto to a given framework release (eg 1.7.4 of react-selecto should install "1.7.4" of selecto not "^1.7.4") - The cause of this issue was hard to track down because after removing my package-lock.json and reinstalling 1.7.4 of react-selecto the issue was still occuring - only after looking into the package-lock.json was it apparent that 1.7.4 had installed 1.9.2 of selecto because of the '^'
boundContainer
is really useful, what I'd like is prop that builds on this functionality by allowing me to specify a fixed height. Meaning that dragging a selection only allows you to modify the width of a selection but not the height. What I'm using this for is to make it possible to create selections on a timeline, so I'm trying to recreate selection behaviour you might find in Final Cut or Premiere.
Selecto throws 'not a valid SSR component error' due to this issue (I believe): sveltejs/sapper#774
Also relevant: rob-balfre/svelte-select#87
Change:
import Selecto from "svelte-selecto";
import Selecto from "svelte-selecto/src/svelte-selecto/Selecto.svelte";
EDIT: Actually this doesn't work, leads to this error: EDIT: Incorrect
500
Cannot read property 'destroy' of undefined
TypeError: Cannot read property 'destroy' of undefined
at Selecto.svelte:65:19
at run (/Users/ben/dev/language-platform/my-project/node_modules/svelte/internal/index.js:22:12)
at Array.forEach (<anonymous>)
at run_all (/Users/ben/dev/language-platform/my-project/node_modules/svelte/internal/index.js:28:9)
at Object.render (/Users/ben/dev/language-platform/my-project/node_modules/svelte/internal/index.js:1686:13)
at render_response (file:///Users/ben/dev/language-platform/my-project/node_modules/@sveltejs/kit/dist/ssr.js:472:28)
at async respond$1 (file:///Users/ben/dev/language-platform/my-project/node_modules/@sveltejs/kit/dist/ssr.js:1324:10)
at async render_page (file:///Users/ben/dev/language-platform/my-project/node_modules/@sveltejs/kit/dist/ssr.js:1386:19)
at async resolve (file:///Users/ben/dev/language-platform/my-project/node_modules/@sveltejs/kit/dist/ssr.js:1647:10)
at async Object.handle (/Users/ben/dev/language-platform/my-project/src/hooks.ts:29:25)
This solution depends upon the uncompiled Selecto component being shipped in the npm package.
## Another solution (untested): Doesn't work in SvelteKit
<!-- {#if (process.browser) } -->
<!-- <Selecto /> -->
<!-- {/if} -->
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.