Add an initialScale to make the MIN_SCALE and MAX_SCALE relative to the graph.
authorymh <ymh.work@gmail.com>
Thu, 24 Oct 2013 15:29:44 +0200
changeset 207 583dc519c5fa
parent 206 e09ff1ce23ba
child 208 0e464687eaee
Add an initialScale to make the MIN_SCALE and MAX_SCALE relative to the graph.
client/js/paper-renderer.js
client/publish-test.html
--- a/client/js/paper-renderer.js	Wed Oct 23 03:09:47 2013 +0200
+++ b/client/js/paper-renderer.js	Thu Oct 24 15:29:44 2013 +0200
@@ -1577,6 +1577,7 @@
     this.notif_$ = this.$.find(".Rk-Notifications");
     paper.setup(this.canvas_$[0]);
     this.scale = 1;
+    this.initialScale = 1;
     this.offset = paper.view.center;
     this.totalScroll = 0;
     this.mouse_down = false;
@@ -2160,7 +2161,7 @@
     this.redrawUsers();
 },
 setScale: function(_newScale, _offset) {
-    if (_newScale > _MIN_SCALE && _newScale < _MAX_SCALE) {
+    if ((_newScale/this.initialScale) > _MIN_SCALE && (_newScale/this.initialScale) < _MAX_SCALE) {
         this.scale = _newScale;
         if (_offset) {
             this.offset = _offset;
@@ -2177,7 +2178,8 @@
             _miny = Math.min.apply(Math, _yy),
             _maxx = Math.max.apply(Math, _xx),
             _maxy = Math.max.apply(Math, _yy);
-        var _scale = Math.max(_MIN_SCALE, Math.min(_MAX_SCALE, (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)));
+        var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));
+        this.initialScale = _scale;
         this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
     }
     if (nodes.length === 1) {
--- a/client/publish-test.html	Wed Oct 23 03:09:47 2013 +0200
+++ b/client/publish-test.html	Thu Oct 24 15:29:44 2013 +0200
@@ -23,10 +23,10 @@
             $(function() {
                 _renkan = new Rkns.Renkan({
                     editor_mode: false,
-                    show_bins: false
+                    show_bins: false,
                 });
                 Rkns.jsonIO(_renkan, {
-                    url: "http://renkan.iri-research.org/renkan/rest/projects/ef7ea617-df99-4c73-b4b6-0408f2e503f3?callback=?"
+                    url: "http://renkan.iri-research.org/renkan/rest/projects/696e5544-3b44-11e3-8312-5fa5e5b09a85?callback=?"
                 });
             });
         </script>