Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double click event #4151

Closed
Charles9292 opened this issue Jul 31, 2017 · 15 comments
Closed

Double click event #4151

Charles9292 opened this issue Jul 31, 2017 · 15 comments

Comments

@Charles9292
Copy link

Hi~
Double click event how to add?
I tried several methods, but failed.
dome

@asturur
Copy link
Member

asturur commented Jul 31, 2017

http://fabricjs.com/docs/fabric.Object.html

Check the event names, double click is included.

@asturur asturur closed this as completed Jul 31, 2017
@Charles9292
Copy link
Author

canvas.on('mouse:dblclick', cb)
canvas.on('event:mousedblclick', cb)

That's right?
But it doesn't work at all

@asturur
Copy link
Member

asturur commented Aug 1, 2017

i use them. what does not work?

@Charles9292
Copy link
Author

I bind double click events in two ways,Double clicking on the element does not make any response

@asturur
Copy link
Member

asturur commented Aug 1, 2017

can you open a simple fiddle with a rect on the canvas?

@Charles9292
Copy link
Author

@Charles9292
Copy link
Author

Charles9292 commented Aug 1, 2017

I used the down event to simulate the double click event
But not the best - -!

let time = 0
let sl = _ => {
  if (time === 0) {
    return time = new Date().getTime()
  }
  if (new Date().getTime() - time < 700) {
    alert('dblclick!')
  }
  time = 0
}
canvas.on('mouse:down', sl)

@asturur
Copy link
Member

asturur commented Aug 1, 2017

Double click support is just on the new 2.0 beta.
If you want to use it before, you need to inspect the iText class and take the double/triple click simulator from there. Is based on mouse down like your.

Alternatively check the PR that enabled dblclick on 2.0 and backport to 1.7.x
#3998

@albert-hoffman
Copy link

@asturur Building an ios App and using fabric canvas in it. Need to use the double tap event on canvas but 'mouse:dblclick' event is not firing on iOS devices. can you tell me how does it work in iPad safari?

this.canvas = new fabric.Canvas('can').set({
    backgroundColor: '#ffffff',
    selection: false,
    perPixelTargetFind: true,
    targetFindTolerance: 70,
    background: 'white',
    enableRetinaScaling: false
});
this.canvas.on('mouse:dblclick', (e1) => {
    console.log('double clicked', e1);
}

@asturur
Copy link
Member

asturur commented May 1, 2020

Yes double click and double tap are 2 different things.
I'm using happily enough hammerJS in a production application and i think we should make a demo with something like that.

Are you using any high level event library?

@albert-hoffman
Copy link

albert-hoffman commented May 1, 2020

@asturur I am using fabricJS with angular 7. I just want to double tab. if you find any demo for a mobile device it will be helpful for me. but thing is that I have already implemented the huge application in fabrics, so I can not abandon fabrics. I have to work out with it. thanks dear

@asturur
Copy link
Member

asturur commented May 1, 2020

Yes but wanting to just double tap, please remember that double tap is not a touch event or a js event. the phones get it and translate in something that is not a double click eventually.
So you need a sort of event manager that will fire the double tap for you.

@Saqib92
Copy link

Saqib92 commented Jan 17, 2023

any update on this? I want double tap(for touch screen) and double click on desktop. its working fine on double click on desktop but not working in touch screens.

@Saqib92
Copy link

Saqib92 commented Jan 18, 2023

Yes double click and double tap are 2 different things. I'm using happily enough hammerJS in a production application and i think we should make a demo with something like that.

Are you using any high level event library?

can you please show a little demo with hammerJS to detect double top on object? I am using Angular v15 with fabricjs.

@Saqib92
Copy link

Saqib92 commented Jan 18, 2023

Yes double click and double tap are 2 different things. I'm using happily enough hammerJS in a production application and i think we should make a demo with something like that.
Are you using any high level event library?

can you please show a little demo with hammerJS to detect double top on object? I am using Angular v15 with fabricjs.

Done with Hammer JS. on double tap event call canvas.getActivebject().

Used this hammer example.

Hammer JS Double Tap Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants