Skip to content

Commit cfd8e36

Browse files
committed
5291: make transform update func in fullLayout
1 parent fe912ae commit cfd8e36

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/components/fx/hover.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var Color = require('../color');
2323
var dragElement = require('../dragelement');
2424
var Axes = require('../../plots/cartesian/axes');
2525
var Registry = require('../../registry');
26-
var plotApi = require('../../plot_api/plot_api');
2726

2827
var helpers = require('./helpers');
2928
var constants = require('./constants');
@@ -341,7 +340,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
341340
xpx = evt.clientX - dbb.left;
342341
ypx = evt.clientY - dbb.top;
343342

344-
plotApi.recalculateTransformInverseIfNecessary(gd);
343+
fullLayout._recalculateTransformInverseIfNecessary(gd);
345344
var transformedCoords = Lib.apply3DTransform(fullLayout._inverseTransform)(xpx, ypx);
346345

347346
xpx = transformedCoords[0];

src/plot_api/plot_api.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,13 +3706,29 @@ function purge(gd) {
37063706
return gd;
37073707
}
37083708

3709+
// determines if the graph div requires a recalculation of its inverse matrix transforms by comparing old + new bounding boxes.
3710+
function recalculateTransformInverseIfNecessary(gd, newBBox) {
3711+
gd = Lib.getGraphDiv(gd);
3712+
var fullLayout = gd._fullLayout;
3713+
if (!newBBox)
3714+
newBBox = gd.getBoundingClientRect();
3715+
if (Lib.domRectsAreEqual(newBBox, fullLayout._lastBBox))
3716+
return;
3717+
var m = fullLayout._inverseTransform = Lib.inverseTransformMatrix(Lib.getFullTransformMatrix(gd));
3718+
fullLayout._inverseScaleX = Math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1] + m[0][2] * m[0][2]);
3719+
fullLayout._inverseScaleY = Math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1] + m[1][2] * m[1][2]);
3720+
fullLayout._lastBBox = gd.getBoundingClientRect();
3721+
}
3722+
37093723
// -------------------------------------------------------
37103724
// makePlotFramework: Create the plot container and axes
37113725
// -------------------------------------------------------
37123726
function makePlotFramework(gd) {
37133727
var gd3 = d3.select(gd);
37143728
var fullLayout = gd._fullLayout;
3715-
recalculateTransformInverseIfNecessary(gd);
3729+
3730+
fullLayout._recalculateTransformInverseIfNecessary = recalculateTransformInverseIfNecessary;
3731+
fullLayout._recalculateTransformInverseIfNecessary(gd);
37163732

37173733
// Plot container
37183734
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
@@ -3857,20 +3873,6 @@ function makePlotFramework(gd) {
38573873
gd.emit('plotly_framework');
38583874
}
38593875

3860-
// determines if the graph div requires a recalculation of its inverse matrix transforms by comparing old + new bounding boxes.
3861-
function recalculateTransformInverseIfNecessary(gd, newBBox = null) {
3862-
gd = Lib.getGraphDiv(gd);
3863-
var fullLayout = gd._fullLayout;
3864-
if (!newBBox)
3865-
newBBox = gd.getBoundingClientRect();
3866-
if (Lib.domRectsAreEqual(newBBox, fullLayout._lastBBox))
3867-
return;
3868-
var m = fullLayout._inverseTransform = Lib.inverseTransformMatrix(Lib.getFullTransformMatrix(gd));
3869-
fullLayout._inverseScaleX = Math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1] + m[0][2] * m[0][2]);
3870-
fullLayout._inverseScaleY = Math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1] + m[1][2] * m[1][2]);
3871-
fullLayout._lastBBox = gd.getBoundingClientRect();
3872-
}
3873-
38743876
exports.animate = animate;
38753877
exports.addFrames = addFrames;
38763878
exports.deleteFrames = deleteFrames;
@@ -3898,6 +3900,4 @@ exports._guiRelayout = guiEdit(relayout);
38983900
exports._guiRestyle = guiEdit(restyle);
38993901
exports._guiUpdate = guiEdit(update);
39003902

3901-
exports.recalculateTransformInverseIfNecessary = recalculateTransformInverseIfNecessary;
3902-
39033903
exports._storeDirectGUIEdit = _storeDirectGUIEdit;

0 commit comments

Comments
 (0)