Browse Source

fix dag zoom (#3103)

Co-authored-by: linhaojie <linhaojie@lizhi.fm>
Co-authored-by: dailidong <dailidong66@gmail.com>
Co-authored-by: bao liang <29528966+lenboo@users.noreply.github.com>
pull/3/MERGE
satcblue 4 years ago committed by GitHub
parent
commit
631cc6ea1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js
  2. 16
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js
  3. 16
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js

2
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/dragZoom.js

@ -29,7 +29,7 @@ DragZoom.prototype.init = function () {
.scaleExtent([0.5, 2]) .scaleExtent([0.5, 2])
.on('zoom', () => { .on('zoom', () => {
this.scale = d3.event.scale 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') $canvas.css('transform-origin', '0 0')
}) })
this.element.call(this.zoom).on('dblclick.zoom', null) this.element.call(this.zoom).on('dblclick.zoom', null)

16
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/jsPlumbHandle.js

@ -31,7 +31,8 @@ import {
rtTasksTpl, rtTasksTpl,
setSvgColor, setSvgColor,
saveTargetarr, saveTargetarr,
rtTargetarrArr rtTargetarrArr,
computeScale
} from './util' } from './util'
import mStart from '@/conf/home/pages/projects/pages/definition/pages/list/_source/start' import mStart from '@/conf/home/pages/projects/pages/definition/pages/list/_source/start'
import multiDrag from './multiDrag' import multiDrag from './multiDrag'
@ -148,12 +149,13 @@ JSP.prototype.draggable = function () {
scope: 'plant', scope: 'plant',
drop: function (ev, ui) { drop: function (ev, ui) {
let id = 'tasks-' + Math.ceil(Math.random() * 100000) // eslint-disable-line let id = 'tasks-' + Math.ceil(Math.random() * 100000) // eslint-disable-line
// Get mouse coordinates
const left = parseInt(ui.offset.left - $(this).offset().left) let scale = computeScale($(this))
let top = parseInt(ui.offset.top - $(this).offset().top) - 10 scale = scale || 1
if (top < 25) {
top = 25 // 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 // Generate template node
$('#canvas').append(rtTasksTpl({ $('#canvas').append(rtTasksTpl({
id: id, id: id,

16
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/plugIn/util.js

@ -130,6 +130,19 @@ const allNodesId = () => {
}) })
return idArr return idArr
} }
/**
* compute scalebecause 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 { export {
rtTargetarrArr, rtTargetarrArr,
@ -139,5 +152,6 @@ export {
isNameExDag, isNameExDag,
setSvgColor, setSvgColor,
allNodesId, allNodesId,
rtBantpl rtBantpl,
computeScale
} }

Loading…
Cancel
Save