client/js/paper-renderer.js
changeset 105 810a1c1015df
parent 95 383d020a8af8
child 110 55454c900296
--- a/client/js/paper-renderer.js	Mon Mar 18 18:05:54 2013 +0100
+++ b/client/js/paper-renderer.js	Tue Mar 19 17:59:34 2013 +0100
@@ -238,10 +238,6 @@
     }
 }
 
-Rkns.Renderer._BaseRepresentation.prototype.resetCoords = function() {
-    this.paper_coords = undefined;
-}
-
 Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
 
 Rkns.Renderer.Node.prototype._init = function() {
@@ -279,7 +275,7 @@
 Rkns.Renderer.Node.prototype.redraw = function() {
     var _model_coords = new paper.Point(this.model.get("position")),
     	_baseRadius = Rkns.Renderer._NODE_SIZE_BASE * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP);
-    if (!this.paper_coords) {
+    if (!this.is_dragging || !this.paper_coords) {
         this.paper_coords = this.renderer.toPaperCoords(_model_coords);
     }
     this.circle_radius = _baseRadius * this.renderer.scale;
@@ -368,6 +364,7 @@
 
 Rkns.Renderer.Node.prototype.paperShift = function(_delta) {
 	if (!this.renderer.renkan.read_only) {
+		this.is_dragging = true;
 		this.paper_coords = this.paper_coords.add(_delta);
     	this.redraw();
 	} else {
@@ -449,6 +446,7 @@
     }
     this.renderer.click_target = null;
     this.renderer.is_dragging = false;
+    this.is_dragging = false;
 }
 
 Rkns.Renderer.Node.prototype.destroy = function(_event) {
@@ -1202,7 +1200,6 @@
 
 Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) {
 	this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
-    this.renderer.resetCoords();
     this.renderer.redraw();
 }
 
@@ -1478,7 +1475,6 @@
     
     paper.view.onResize = function(_event) {
     	_this.offset = _this.offset.add(_event.delta.divide(2));
-        _this.resetCoords();
         _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size)
         _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
         _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
@@ -1576,7 +1572,6 @@
 
 Rkns.Renderer.Scene.prototype.setScale = function(_newScale) {
     this.scale = _newScale;
-    this.resetCoords();
     this.redraw();
 }
 
@@ -1606,12 +1601,6 @@
     this.redraw();
 }
 
-Rkns.Renderer.Scene.prototype.resetCoords = function(_point) {
-    _(this.representations).each(function(r) {
-        r.resetCoords();
-    });
-}
-
 Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {
     return _point.multiply(this.scale).add(this.offset);
 }
@@ -1731,7 +1720,6 @@
 
 Rkns.Renderer.Scene.prototype.paperShift = function(_delta) {
 	this.offset = this.offset.add(_delta);
-    this.resetCoords();
     this.redraw();
 }