-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve the click/doubleClick event with options how these should be fired. #203
Comments
Hi Dponch, You could create a timeout function in your onclick function with a timeout you decide. If you have not received a doubleclick by then, interpret it as a click.
Regards, Alex |
Hi, That's a good idea, thanks for your help.
I'm using Firefox30. Could it be a problem? |
Hi Dponch, You're right! I forgot about the second click hehe :). This should work:
Let me know if this works! |
It works perfectly! Many thanks!!! |
You're welcome. We have not put this in vis because it would delay the click event. If a user doesnt use the double click that would be annoying :). |
Alex, Sorry to reopen an old ticket, but I came here looking for a solution to the multiple event issue. I completely understand why you wouldn't want the code above which delays the
Is there a case for ever getting the second
This reduces a double-click on the network to these events:
which is actually exactly what I want. People who don't want the first The only side-effect of this would be that a double-click can't be followed by a single-click within the threshold time - but again, that's pretty normal I think. |
Hi Dave, That's perfectly fine. This code was just a suggestion or idea. To answer your question, no I don't think it's up to us to determine if people want a click after a double click. Since the solution is very easy, I'd prefer to leave that up to the devs using vis. Regards, Alex |
It makes sense to me to just have the I can't come up with a use case where you would want |
Double click can color a node and then click again somewhere else to deselect? |
Nevermind, misread the issue. |
I think there are three use cases:
I think 1. and 2. are important. We could realize the third option as well, that requires the developer to set an option to specify this behavior. |
The first item, only using click, makes it unacceptable for vis to eat a click for the doubleClick event. Since the events are always fired, regardless of listeners, what do you suggest? Options to pass to network on init? If the default settings are anything other then it is now it could give unexpected behaviour. Also the doubleClick threshold (time to wait) could be customised. I'm not sure if I'd want to have people use the code as stated above or add more options. What do you think? |
Why? Seen from a user perspective, the user either does a single click (resulting in a So I think we can keep current behavior, except for the second Option 3 is an extra, that would require configuration via the options. |
If you're only using clicks, and you are clicking twice fast I find it strange that you'd have to listen to the doubleClick event instead of just the click event because you might lose a click. Now vis gives you exactly what happens. There ARE two clicks and they were fast enough that it could be called a double click. I would argue this gives the most reliable result. We could add event options to streamline this if needed. |
yeah, that's true. We could introduce an option for this with three different modes. |
I'm torn between Alex's last comment (what you get is exactly what is happening), and the vast experience of developing on, e.g. Win32 where that isn't what you get. I'm not saying Win32 is right here, just that I was confused by the event stream being 'different'. I think a 'doubleClickMode' option would be ideal - I'll leave it to someone else to argue what the default should be :). Then I can code on the user side exactly as I do in other apps, and get the same events I would normally expect. Here's my suggestion: When the user just 'clicks', you should always get a
|
Hi Dave, I would argue that 1 and 4 are the same. That leaves:
Hows that? If the user chooses to use the double click he'll have to work with the initial click anyway. I'm opposed to delaying ALL clicks, seems nasty. Regards |
Agree 1 isn't necessary as 1 == 4 if you don't subscribe to the doubleclick event. Not sure what I'd strongly argue for including case 2. though, with a warning in the docs that it will delay clicks. If that's the behaviour you want, your user-side click handler will end up being delayed anyway, and this way it makes the user-side code much cleaner and easier to understand. IMO, we shouldn't be putting that level of click handling stuff in the application - it would be much nicer if the library did it for us. Understand this makes vis messier inside though. How about this version?
|
I would argue that doubleClick: false in my example completely removes the double click functionality from the network. If true, we can delay all clicks and hide the second one. The user would essentially be "toggling" the double click functionality on or off. |
I'm still a little unclear what the difference is between turning doubleClick off, and simply not subscribing to the doubleClick event. But anyway, would |
if false, the user would get click - click, if true, the user would get click doubleclick. As for breaking old code, yes that is possible.. we could still emit the doubleclick so if false the user would get click - doubleclick - click as it is now. |
I think that's basically cases 0 and 1 in my list. Case 2 is the 'new' one, where click = In your last scenario, supposing I wanted a user's 'click' to do something, but a user's 'double-click' to do nothing. I'd have to subscribe to the |
Hi, Over the last year a lot of feature requests have been made. We have just introduced our new website which has a list of the requested features. We have placed this request on that list. The list can be found here: An explaination of the new system can be found here: I would like to stress that this does not mean we abandon this request. Discussion here will continue if needed on this feature but we will close it to keep our Github issue page more of a bug-todo list. Future feature requests will still be made here and then added to the website by us. Regards, Alex |
Reopening as Feature-Request issue (see #2114). |
Onclick of buttons how to show the particular segments of node.In vis js. |
@supriyasureshg You commented here so I'll remove the label |
It is certainly very nice and ergonomic to be able to distinguish different actions using the same left mouse button.
|
I'd recommend to use Rx.js |
I have following work to do :
I have written a function and map it to the clickCallBack of Dygraph. Things are working fine but soon you double click on graph will again call the function and I lost default feature of reset zoom. I know there should be something to differentiate the single click vs double click. The solution above told will not work for me since I need to fetch x axis value and click on container which holds graph will not fetch me point on which click was made. I have even tried interactionModel but facing same problem. Please let me know your suggestion. Thanks, |
const source = Rx.Observable.fromEvent(container, 'click')
.map(({ offsetX }) => offsetX)
.throttleTime(300)
.subscribe(offsetX => {
console.log(offsetX);
// make ajax call here
}); |
@MishaMykhalyukCogniance will it work for container which holds dygraph based graph. I have not used Rx before. |
@rohit2503 It should work. I've checked it on official site: |
Sorry I tried but it's not working. I have used this RX js https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.0/rxjs.umd.js in my code. When I am typing in browser console Rx it is giving error Rx not found. |
Hi,
I want to use the events click and doubleclick on a network graph, but I realized that the event doubleclick triggers the event click, so when I doubleclick 2 functions are called.
Is there a way to avoid this?
Thanks
The text was updated successfully, but these errors were encountered: