Added off-state event for hover picking

0.2
Robin Hawkes 2015-03-07 23:15:33 +00:00
rodzic fb49a43629
commit 9904d99d7b
4 zmienionych plików z 33 dodań i 7 usunięć

Wyświetl plik

@ -9110,8 +9110,6 @@ if (typeof window === undefined) {
self.world.addPickable(mesh, geom.id);
VIZI.Messenger.on("pick-hover:" + geom.id, function() {
console.log("Hovered:", geom.id);
self.lastPickedId = geom.id;
if (self.pickedMesh) {
@ -9140,6 +9138,12 @@ if (typeof window === undefined) {
self.add(self.pickedMesh);
});
VIZI.Messenger.on("pick-off:" + geom.id, function() {
if (self.pickedMesh) {
self.remove(self.pickedMesh);
}
});
VIZI.Messenger.on("pick-click:" + geom.id, function() {
// TODO: Do something to the choropleth when clicked
console.log("Clicked:", geom.id);
@ -10168,6 +10172,8 @@ if (typeof window === undefined) {
* @author Robin Hawkes - vizicities.com
*/
// TODO: Emit event when finished hovering a ref - "pick-off:id"?
(function() {
"use strict";
@ -10210,11 +10216,19 @@ if (typeof window === undefined) {
var ref = self.pick(relativePos);
if (!ref) {
if (self.lastPickedIdHover) {
// Emit event with picked id (for other modules to reference from)
VIZI.Messenger.emit("pick-off:" + self.lastPickedIdHover);
self.lastPickedIdHover = undefined;
}
return;
}
if (self.lastPickedIdHover && self.lastPickedIdHover === ref.id) {
return;
} else if (self.lastPickedIdHover && self.lastPickedIdHover !== ref.id) {
// Emit event with picked id (for other modules to reference from)
VIZI.Messenger.emit("pick-off:" + self.lastPickedIdHover);
}
// Emit event with picked id (for other modules to reference from)

6
build/vizi.min.js vendored

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -165,8 +165,6 @@
self.world.addPickable(mesh, geom.id);
VIZI.Messenger.on("pick-hover:" + geom.id, function() {
console.log("Hovered:", geom.id);
self.lastPickedId = geom.id;
if (self.pickedMesh) {
@ -195,6 +193,12 @@
self.add(self.pickedMesh);
});
VIZI.Messenger.on("pick-off:" + geom.id, function() {
if (self.pickedMesh) {
self.remove(self.pickedMesh);
}
});
VIZI.Messenger.on("pick-click:" + geom.id, function() {
// TODO: Do something to the choropleth when clicked
console.log("Clicked:", geom.id);

Wyświetl plik

@ -49,11 +49,19 @@
var ref = self.pick(relativePos);
if (!ref) {
if (self.lastPickedIdHover) {
// Emit event with picked id (for other modules to reference from)
VIZI.Messenger.emit("pick-off:" + self.lastPickedIdHover);
self.lastPickedIdHover = undefined;
}
return;
}
if (self.lastPickedIdHover && self.lastPickedIdHover === ref.id) {
return;
} else if (self.lastPickedIdHover && self.lastPickedIdHover !== ref.id) {
// Emit event with picked id (for other modules to reference from)
VIZI.Messenger.emit("pick-off:" + self.lastPickedIdHover);
}
// Emit event with picked id (for other modules to reference from)