[Bps-public-commit] rt-extension-lifecycleui branch, master, updated. 7d5755a6787e7fa8b9dd741982a08846bc4f6de4

Shawn Moore shawn at bestpractical.com
Tue Sep 26 16:37:17 EDT 2017


The branch, master has been updated
       via  7d5755a6787e7fa8b9dd741982a08846bc4f6de4 (commit)
       via  9ff5894ee7351be7974fdd85de503b692c1c53e0 (commit)
      from  e0d6f9d71579551dc89a37b69d499be7ff85fbd5 (commit)

Summary of changes:
 static/js/lifecycleui-viewer.js | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 9ff5894ee7351be7974fdd85de503b692c1c53e0
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 26 20:36:01 2017 +0000

    Factor out a _setZoom(zoom, animated)

diff --git a/static/js/lifecycleui-viewer.js b/static/js/lifecycleui-viewer.js
index 6ea3a19..64cb963 100644
--- a/static/js/lifecycleui-viewer.js
+++ b/static/js/lifecycleui-viewer.js
@@ -49,17 +49,21 @@ jQuery(function () {
         }
     }
 
-    Viewer.prototype.resetZoom = function (animated) {
+    Viewer.prototype._setZoom = function (zoom, animated) {
         if (animated) {
             this.svg.transition()
                     .duration(750*this.animationFactor)
-                    .call(this._zoom.transform, this._zoomIdentity);
+                    .call(this._zoom.transform, zoom);
         }
         else {
-            this.svg.call(this._zoom.transform, this._zoomIdentity);
+            this.svg.call(this._zoom.transform, zoom);
         }
     };
 
+    Viewer.prototype.resetZoom = function (animated) {
+        this._setZoom(this._zoomIdentity, animated);
+    };
+
     Viewer.prototype.didEnterStatusNodes = function (statuses) { };
     Viewer.prototype.didEnterTransitions = function (paths) { };
     Viewer.prototype.didEnterTextDecorations = function (labels) { };

commit 7d5755a6787e7fa8b9dd741982a08846bc4f6de4
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 26 20:36:16 2017 +0000

    Initial implementation of zoom to fit
    
    It works well on the lifecycle builder UI, but oddly, not on ticket display

diff --git a/static/js/lifecycleui-viewer.js b/static/js/lifecycleui-viewer.js
index 64cb963..b711b1d 100644
--- a/static/js/lifecycleui-viewer.js
+++ b/static/js/lifecycleui-viewer.js
@@ -64,6 +64,22 @@ jQuery(function () {
         this._setZoom(this._zoomIdentity, animated);
     };
 
+    Viewer.prototype.zoomToFit = function (animated) {
+        var bounds = this.transformContainer.node().getBBox();
+        var parent = this.transformContainer.node().parentElement;
+        var fullWidth = parent.clientWidth || parent.parentNode.clientWidth,
+            fullHeight = parent.clientHeight || parent.parentNode.clientHeight;
+        var width = bounds.width,
+            height = bounds.height;
+        var midX = bounds.x + width / 2,
+            midY = bounds.y + height / 2;
+        var scale = 0.75 / Math.max(width / fullWidth, height / fullHeight);
+        var tx = fullWidth / 2 - scale * midX;
+        var ty = fullHeight / 2 - scale * midY;
+
+        this._setZoom(this._zoomIdentity.translate(tx, ty).scale(scale), animated);
+    };
+
     Viewer.prototype.didEnterStatusNodes = function (statuses) { };
     Viewer.prototype.didEnterTransitions = function (paths) { };
     Viewer.prototype.didEnterTextDecorations = function (labels) { };

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list