var svg = Snap("#house");
Snap.load("images/house/optimised.svg", function (f) {
var g = f.select("g"),
lamp = f.select("#Lamp"),
laptop = f.select("#Laptop"),
wc = f.select("#WC"),
sink = f.select("#Sink");
/////////////////
// Interaction
/////////////////
lamp.click(onElementClicked);
laptop.click(onElementClicked);
wc.click(onElementClicked);
sink.click(onElementClicked);
// Click on the whole graphic
$(document).click(function(e) {
$('.active-graphic').removeAttr("class");
});
// Add loaded graphic (g) to svg element (svg)
svg.append(g);
});
var onElementClicked = function(evt) {
var x = this.getBBox().x,
y = this.getBBox().y;
console.log("x: " + this.getBBox().x + ", y: " + this.getBBox().y);
activateGraphic(this);
evt.stopPropagation();
}