Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Fix click and doubleclick events on items #2988

Merged
merged 36 commits into from
May 3, 2017

Conversation

yotamberk
Copy link
Contributor

@yotamberk yotamberk commented Apr 16, 2017

There was a major bug I encountered trying to catch click and doubleclick events on selected items.
This PR solves this bug. (continues #2473 to fully solve: #2421, )
checkout the vis/examples/timeline/interaction/eventListeners.html example in this PR to see the click\doubleclick event getting fired when an item is already selected.

Copy link
Contributor

@wimrijnders wimrijnders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best review I can do without testing the changes - I don't see how I can do that now.

Also, extra: in the timeline basicUsage example, I get this.groupsData === null in the first test of ItemSet.prototype.groupFromTarget(). Is that supposed to happen?

@@ -145,16 +145,26 @@ Item.prototype.repositionY = function() {
*/
Item.prototype._repaintDragCenter = function () {
if (this.selected && this.options.editable.updateTime && !this.dom.dragCenter) {
var me = this;

var me = this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon

// create and show drag area
var dragCenter = document.createElement('div');
dragCenter.className = 'vis-drag-center';
dragCenter.dragCenterItem = this;
this.hammer = new Hammer(dragCenter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So hammer is now a member var; but it will be overwritten on every redraw. Is this what is supposed to happen? Doesn't look right to me.

I would expect it to be either a local var, or a more permanent member var.

item: me.id
});
});
this.hammer.on('doubletap', function (event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do tap and doubletap always fire consecutively? Or is it either one or the other?
In the latter case, please consider usage of requireFailure().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't fire consecutively. It's one or the other. There is no need for requireFailure() here because it hasn't been used anywhere else. I can add it in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

event.stopPropagation();
me.parent.itemSet._onUpdateItem(me);
me.parent.itemSet.body.emitter.emit('doubleClick', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trusting that this block is correct; it is congruent to click above, so it looks OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@yotamberk
Copy link
Contributor Author

yotamberk commented May 3, 2017

@wimrijnders

Also, extra: in the timeline basicUsage example, I get this.groupsData === null in the first test of ItemSet.prototype.groupFromTarget(). Is that supposed to happen?

not sure when this was introduced.
I'll take a look and fix in another PR

// create and show drag area
var dragCenter = document.createElement('div');
dragCenter.className = 'vis-drag-center';
dragCenter.dragCenterItem = this;
this.hammer = new Hammer(dragCenter)
var hammer = new Hammer(dragCenter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@wimrijnders wimrijnders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now it is perfect.

@yotamberk yotamberk merged commit 10927b5 into almende:develop May 3, 2017
@mojoaxel mojoaxel added this to the Minor Release v4.20 milestone May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants