You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by le...@apache.org on 2020/07/02 06:52:46 UTC
[incubator-dolphinscheduler] branch 1.3.1-release updated: fix dag
zoom (#3103)
This is an automated email from the ASF dual-hosted git repository.
leonbao pushed a commit to branch 1.3.1-release
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/1.3.1-release by this push:
new 78c7dc1 fix dag zoom (#3103)
78c7dc1 is described below
commit 78c7dc104df81ddeaa2851e4f2e4cbc1778a5e1e
Author: satcblue <40...@users.noreply.github.com>
AuthorDate: Thu Jul 2 14:19:04 2020 +0800
fix dag zoom (#3103)
Co-authored-by: linhaojie <li...@lizhi.fm>
Co-authored-by: dailidong <da...@gmail.com>
Co-authored-by: bao liang <29...@users.noreply.github.com>
---
.../js/conf/home/pages/dag/_source/plugIn/dragZoom.js | 2 +-
.../conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js | 16 +++++++++-------
.../src/js/conf/home/pages/dag/_source/plugIn/util.js | 16 +++++++++++++++-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js
index 2027f8e..009c82b 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js
@@ -29,7 +29,7 @@ DragZoom.prototype.init = function () {
.scaleExtent([0.5, 2])
.on('zoom', () => {
this.scale = d3.event.scale
- $canvas.css('transform', 'translate(' + d3.event.translate[0] + 'px,' + d3.event.translate[1] + 'px) scale(' + this.scale + ')')
+ $canvas.css('transform', 'scale(' + this.scale + ')')
$canvas.css('transform-origin', '0 0')
})
this.element.call(this.zoom).on('dblclick.zoom', null)
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js
index a40a76f..8dbc634 100755
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js
@@ -31,7 +31,8 @@ import {
rtTasksTpl,
setSvgColor,
saveTargetarr,
- rtTargetarrArr
+ rtTargetarrArr,
+ computeScale
} from './util'
import mStart from '@/conf/home/pages/projects/pages/definition/pages/list/_source/start'
@@ -144,12 +145,13 @@ JSP.prototype.draggable = function () {
scope: 'plant',
drop: function (ev, ui) {
let id = 'tasks-' + Math.ceil(Math.random() * 100000) // eslint-disable-line
- // Get mouse coordinates
- const left = parseInt(ui.offset.left - $(this).offset().left)
- let top = parseInt(ui.offset.top - $(this).offset().top) - 10
- if (top < 25) {
- top = 25
- }
+
+ let scale = computeScale($(this))
+ scale = scale || 1
+
+ // Get mouse coordinates and after scale coordinate
+ const left = parseInt(ui.offset.left - $(this).offset().left) / scale
+ const top = parseInt(ui.offset.top - $(this).offset().top) / scale
// Generate template node
$('#canvas').append(rtTasksTpl({
id: id,
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js
index 84b01a5..0b472b6 100755
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js
@@ -130,6 +130,19 @@ const allNodesId = () => {
})
return idArr
}
+/**
+ * compute scaleļ¼because it cant get from jquery directly
+ * @param el element
+ * @returns {boolean|number}
+ */
+const computeScale = function (el) {
+ const matrix = el.css('transform')
+ if (!matrix || matrix === 'none') {
+ return false
+ }
+ const values = matrix.split('(')[1].split(')')[0].split(',')
+ return Math.sqrt(values[0] * values[0] + values[1] * values[1])
+}
export {
rtTargetarrArr,
@@ -139,5 +152,6 @@ export {
isNameExDag,
setSvgColor,
allNodesId,
- rtBantpl
+ rtBantpl,
+ computeScale
}