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

MouseMove event prevents onClick handler from firing #142

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Source/Extras/Extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Extras.Classes.Events = new Class({

this.touchMoved = false;
this.moved = false;

this.lastPosition = false;
},

setAsProperty: $.lambda(true),
Expand All @@ -277,6 +277,7 @@ Extras.Classes.Events = new Class({
}
this.pressed = this.moved = false;
}
this.lastPosition = false;
},

onMouseOut: function(e, win, event) {
Expand Down Expand Up @@ -313,9 +314,16 @@ Extras.Classes.Events = new Class({
},

onMouseMove: function(e, win, event) {
var label, evt = $.event.get(e, win);
var label, evt = $.event.get(e, win),
// Check if mouse actually moved
didMove = this.lastPosition && this.mouseDidMove(e);
// Update last position to be current position for next time
this.lastPosition = {
x: e.clientX,
y: e.clientY
};
if(this.pressed) {
this.moved = true;
this.moved = didMove;
this.config.onDragMove(this.pressed, event, evt);
return;
}
Expand Down Expand Up @@ -388,6 +396,12 @@ Extras.Classes.Events = new Class({
}
this.touched = this.touchMoved = false;
}
},
mouseDidMove: function(event) {
var deltaX = event.clientX - this.lastPosition.x,
deltaY = event.clientY - this.lastPosition.y,
movement = deltaX * deltaX + deltaY * deltaY;
return movement > 0;
}
});

Expand Down
2 changes: 1 addition & 1 deletion Source/Graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ $jit.Graph = new Class({
this.nodes[obj.id] = new Graph.Node($.extend({
'id': obj.id,
'name': obj.name,
'data': $.merge(obj.data || {}, {}),
'data': obj.data || {},
Copy link
Owner

Choose a reason for hiding this comment

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

Why are you removing the merge operation? The idea is to clone the object.

Copy link
Author

Choose a reason for hiding this comment

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

In my application I'm adding Ember.js objects to my the data hash. Ember objects have observer functions tied to data properties that will get fired when a property is modified. The merge operation copies the data but in doing so unsets the observers.

In my case I don't want to have a clone of the object in this hash, I want the object itself so that the object state remains consistent within the application. I hadn't intended for this change to be a part of the pull request, but why does the object need to be cloned in the first place?

'adjacencies': edges
}, this.opt.Node),
this.opt.klass,
Expand Down
4 changes: 4 additions & 0 deletions Source/Visualizations/Spacetree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,10 @@ $jit.ST.Label.DOM = new Class({
sy = canvas.scaleOffsetY,
posx = pos.x * sx + ox,
posy = pos.y * sy + oy;

Copy link
Owner

Choose a reason for hiding this comment

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

What is this for?

Copy link
Author

Choose a reason for hiding this comment

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

When using HTML labels and zooming in/out of the Spacetree the label positioning becomes erratic. Current label positioning calculations use the original node width/height unscaled which seemed to be the cause. Scaling the width/height fixed this for me.

Copy link
Author

Choose a reason for hiding this comment

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

Another issue with HTML labels is that the size of the label doesn't scale at all with zooming, though I'm able to account for this within the onPlaceLabel hook.

// Scale node width/height
w = w * sx;
h = h * sy;

if(dim.align == "center") {
labelPos= {
Expand Down
1 change: 0 additions & 1 deletion web

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions webpy/.gitignore

This file was deleted.