(gd, shapePath, shapeOptions, index, shapeLayer, editHelpers)
| 284 | } |
| 285 | |
| 286 | function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer, editHelpers) { |
| 287 | var MINWIDTH = 10; |
| 288 | var MINHEIGHT = 10; |
| 289 | |
| 290 | var xPixelSized = shapeOptions.xsizemode === 'pixel'; |
| 291 | var yPixelSized = shapeOptions.ysizemode === 'pixel'; |
| 292 | var isLine = shapeOptions.type === 'line'; |
| 293 | var isPath = shapeOptions.type === 'path'; |
| 294 | |
| 295 | var modifyItem = editHelpers.modifyItem; |
| 296 | |
| 297 | var x0, y0, x1, y1, xAnchor, yAnchor; |
| 298 | var n0, s0, w0, e0, optN, optS, optW, optE; |
| 299 | var pathIn; |
| 300 | |
| 301 | var shapeGroup = d3.select(shapePath.node().parentNode); |
| 302 | |
| 303 | // setup conversion functions |
| 304 | var xa = Axes.getFromId(gd, shapeOptions.xref); |
| 305 | var xRefType = Axes.getRefType(shapeOptions.xref); |
| 306 | var ya = Axes.getFromId(gd, shapeOptions.yref); |
| 307 | var yRefType = Axes.getRefType(shapeOptions.yref); |
| 308 | var shiftXStart = shapeOptions.x0shift; |
| 309 | var shiftXEnd = shapeOptions.x1shift; |
| 310 | var shiftYStart = shapeOptions.y0shift; |
| 311 | var shiftYEnd = shapeOptions.y1shift; |
| 312 | var x2p = function (v, shift) { |
| 313 | var dataToPixel = helpers.getDataToPixel(gd, xa, shift, false, xRefType); |
| 314 | return dataToPixel(v); |
| 315 | }; |
| 316 | var y2p = function (v, shift) { |
| 317 | var dataToPixel = helpers.getDataToPixel(gd, ya, shift, true, yRefType); |
| 318 | return dataToPixel(v); |
| 319 | }; |
| 320 | var p2x = helpers.getPixelToData(gd, xa, false, xRefType); |
| 321 | var p2y = helpers.getPixelToData(gd, ya, true, yRefType); |
| 322 | |
| 323 | var sensoryElement = obtainSensoryElement(); |
| 324 | var dragOptions = { |
| 325 | element: sensoryElement.node(), |
| 326 | gd: gd, |
| 327 | prepFn: startDrag, |
| 328 | doneFn: endDrag, |
| 329 | clickFn: abortDrag |
| 330 | }; |
| 331 | var dragMode; |
| 332 | |
| 333 | dragElement.init(dragOptions); |
| 334 | |
| 335 | sensoryElement.node().onmousemove = updateDragMode; |
| 336 | |
| 337 | function obtainSensoryElement() { |
| 338 | return isLine ? createLineDragHandles() : shapePath; |
| 339 | } |
| 340 | |
| 341 | function createLineDragHandles() { |
| 342 | var minSensoryWidth = 10; |
| 343 | var sensoryWidth = Math.max(shapeOptions.line.width, minSensoryWidth); |
no test coverage detected
searching dependent graphs…