8000 Update Tocca.js by DanielJMaxwell · Pull Request #16 · GianlucaGuarini/Tocca.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Tocca.js #16

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

Merged
merged 2 commits into from
Apr 2, 2015
Merged

Conversation

DanielJMaxwell
Copy link
Contributor

Only trigger a double click event if both clicks were on the correct element.

Only trigger a double click event if both clicks were on the correct element.
@GianlucaGuarini
Copy link
Owner

Sorry I do not get it? Could you explain what you are trying to achieve with this pull request?

@DanielJMaxwell
Copy link
Contributor Author

I seem to have accidentally added two changes rather than one. It should have been one change. I'll explain what I intended.

It was to address a bug, in which you can sometimes get a dbltap event when in fact you have tapped on two different elements. You can recreate it like this:

  • attach a dbltap event to two adjacent elements, or (as I did) one element inside/overlapping another.
  • tap/click the first element, then quickly tap/click the second element.

Currently, the code doesn't check whether the second tap was on the same element as the first tap, so it is treated as a dbltap on the second element.

I think it should only fire a tbltap event if both taps occurred on the same element.

The suggested change checks, on line 133, whether the target was the same. It also adds 'target' to the list of variables on line 154 (now 155).

Does that make sense? Would you like me to submit it again as a single change?

@GianlucaGuarini
Copy link
Owner

Ah ok I got it. But in your pull request you do not check the target element right? Isn't there something missing?

Previous version mistakenly omitted the change to lines 133/4.
@DanielJMaxwell
Copy link
Contributor Author

I made a mistake - there are changes in two places and I missed one, sorry. I'm not very familiar with git, so I've been fighting with it a little :/

Lines 133 and 134 should read:

            sendEvent(e.target, ((tapNum === 2)&&(target===e.target)) ? 'dbltap' : 'tap', e);
            target= e.target;

and Line 155 should read:

    currX, currY, cachedX, cachedY, tapTimer, timestamp,target;

(ie. I have added 'target' to the end). The correct file is this one

GianlucaGuarini added a commit that referenced this pull request Apr 2, 2015
@GianlucaGuarini GianlucaGuarini merged commit d4e4284 into GianlucaGuarini:master Apr 2, 2015
@DanielJMaxwell DanielJMaxwell deleted the patch-2 branch April 2, 2015 09:52
@GianlucaGuarini
Copy link
Owner

Thanks @DanielJMaxwell your patch now was merged and it's in the new Tocca.js 0.1.4

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

Successfully merging this pull request may close these issues.

2 participants
0