diff --git a/README.md b/README.md index 312cd2b1..f7c51be9 100644 --- a/README.md +++ b/README.md @@ -592,6 +592,12 @@ $('#chartContainerId').orgchart(options); zoombooleannofalseUsers could zoomin/zoomout the orgchart by mouse wheel if they enable this option. + + zoominLimitnumberno7Users are allowed to set a zoom-in limit. + + + zoomoutLimitnumberno0.5Users are allowed to set a zoom-out limit. + directionstringno"t2b"The available values are t2b(implies "top to bottom", it's default value), b2t(implies "bottom to top"), l2r(implies "left to right"), r2l(implies "right to left"). diff --git a/bower.json b/bower.json index 4a78f918..087796e1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "orgchart", - "version": "1.3.5", + "version": "1.3.6", "homepage": "https://github.com/dabeng/OrgChart", "authors": [ "dabeng " diff --git a/dist/js/jquery.orgchart.js b/dist/js/jquery.orgchart.js index 6c993f0e..d548b391 100644 --- a/dist/js/jquery.orgchart.js +++ b/dist/js/jquery.orgchart.js @@ -34,7 +34,9 @@ 'draggable': false, 'direction': 't2b', 'pan': false, - 'zoom': false + 'zoom': false, + 'zoominLimit': 7, + 'zoomoutLimit': 0.5 }; switch (options) { @@ -293,14 +295,24 @@ } function setChartScale($chart, newScale) { + var opts = $chart.data('options'); var lastTf = $chart.css('transform'); + var matrix = ''; + var targetScale = 1; if (lastTf === 'none') { $chart.css('transform', 'scale(' + newScale + ',' + newScale + ')'); } else { + matrix = lastTf.split(','); if (lastTf.indexOf('3d') === -1) { - $chart.css('transform', lastTf + ' scale(' + newScale + ',' + newScale + ')'); + targetScale = window.parseFloat(matrix[3]) * newScale; + if (targetScale > opts.zoomoutLimit && targetScale < opts.zoominLimit) { + $chart.css('transform', lastTf + ' scale(' + newScale + ',' + newScale + ')'); + } } else { - $chart.css('transform', lastTf + ' scale3d(' + newScale + ',' + newScale + ', 1)'); + targetScale = window.parseFloat(matrix[1]) * newScale; + if (targetScale > opts.zoomoutLimit && targetScale < opts.zoominLimit) { + $chart.css('transform', lastTf + ' scale3d(' + newScale + ',' + newScale + ', 1)'); + } } } } diff --git a/package.json b/package.json index f991b628..318c95fb 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orgchart", - "version": "1.3.5", + "version": "1.3.6", "description": "Simple and direct organization chart(tree-like hierarchy) plugin based on pure DOM and jQuery.", "main": "./dist/js/jquery.orgchart.js", "style": [