Skip to content

Commit fe5ee9b

Browse files
committed
use shorter inverse keys for css transforms in gd._fullLayout
1 parent 0b2397a commit fe5ee9b

File tree

11 files changed

+33
-33
lines changed

11 files changed

+33
-33
lines changed

src/components/fx/hover.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ exports.loneHover = function loneHover(hoverItems, opts) {
194194
d.offset -= anchor;
195195
});
196196

197-
var scaleX = opts.gd._fullLayout._inverseScaleX;
198-
var scaleY = opts.gd._fullLayout._inverseScaleY;
197+
var scaleX = opts.gd._fullLayout._invScaleX;
198+
var scaleY = opts.gd._fullLayout._invScaleY;
199199
alignHoverText(hoverLabel, fullOpts.rotateLabels, scaleX, scaleY);
200200

201201
return multiHover ? hoverLabel : hoverLabel.node();
@@ -341,7 +341,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
341341
ypx = evt.clientY - dbb.top;
342342

343343
fullLayout._calcInverseTransform(gd);
344-
var transformedCoords = Lib.apply3DTransform(fullLayout._inverseTransform)(xpx, ypx);
344+
var transformedCoords = Lib.apply3DTransform(fullLayout._invTransform)(xpx, ypx);
345345

346346
xpx = transformedCoords[0];
347347
ypx = transformedCoords[1];
@@ -726,7 +726,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
726726

727727
if(!helpers.isUnifiedHover(hovermode)) {
728728
hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
729-
alignHoverText(hoverLabels, rotateLabels, fullLayout._inverseScaleX, fullLayout._inverseScaleY);
729+
alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
730730
} // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
731731
// we should improve the "fx" API so other plots can use it without these hack.
732732
if(evt.target && evt.target.tagName) {

src/lib/svg_text_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ function alignHTMLWith(_base, container, options) {
750750
var gd = options.gd || {};
751751
if(options.gd) {
752752
gd._fullLayout._calcInverseTransform(gd);
753-
var transformedCoords = Lib.apply3DTransform(gd._fullLayout._inverseTransform)(x0, y0);
753+
var transformedCoords = Lib.apply3DTransform(gd._fullLayout._invTransform)(x0, y0);
754754
x0 = transformedCoords[0];
755755
y0 = transformedCoords[1];
756756
}

src/plot_api/plot_api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3713,9 +3713,9 @@ function calcInverseTransform(gd) {
37133713
var newBBox = gd.getBoundingClientRect();
37143714
if(Lib.equalDomRects(newBBox, fullLayout._lastBBox)) return;
37153715

3716-
var m = fullLayout._inverseTransform = Lib.inverseTransformMatrix(Lib.getFullTransformMatrix(gd));
3717-
fullLayout._inverseScaleX = Math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1] + m[0][2] * m[0][2]);
3718-
fullLayout._inverseScaleY = Math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1] + m[1][2] * m[1][2]);
3716+
var m = fullLayout._invTransform = Lib.inverseTransformMatrix(Lib.getFullTransformMatrix(gd));
3717+
fullLayout._invScaleX = Math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1] + m[0][2] * m[0][2]);
3718+
fullLayout._invScaleY = Math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1] + m[1][2] * m[1][2]);
37193719
fullLayout._lastBBox = newBBox;
37203720
}
37213721

src/plots/cartesian/dragbox.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
166166

167167
recomputeAxisLists();
168168

169-
scaleX = gd._fullLayout._inverseScaleX;
170-
scaleY = gd._fullLayout._inverseScaleY;
169+
scaleX = gd._fullLayout._invScaleX;
170+
scaleY = gd._fullLayout._invScaleY;
171171

172172
if(!allFixedRanges) {
173173
if(isMainDrag) {
@@ -336,7 +336,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
336336
y0 = startY - dragBBox.top;
337337

338338
gd._fullLayout._calcInverseTransform(gd);
339-
var transformedCoords = Lib.apply3DTransform(gd._fullLayout._inverseTransform)(x0, y0);
339+
var transformedCoords = Lib.apply3DTransform(gd._fullLayout._invTransform)(x0, y0);
340340
x0 = transformedCoords[0];
341341
y0 = transformedCoords[1];
342342

src/plots/cartesian/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
6969
var y0 = startY - dragBBox.top;
7070

7171
fullLayout._calcInverseTransform(gd);
72-
var transformedCoords = Lib.apply3DTransform(fullLayout._inverseTransform)(x0, y0);
72+
var transformedCoords = Lib.apply3DTransform(fullLayout._invTransform)(x0, y0);
7373
x0 = transformedCoords[0];
7474
y0 = transformedCoords[1];
75-
var scaleX = fullLayout._inverseScaleX;
76-
var scaleY = fullLayout._inverseScaleY;
75+
var scaleX = fullLayout._invScaleX;
76+
var scaleY = fullLayout._invScaleY;
7777

7878
var x1 = x0;
7979
var y1 = y0;

src/plots/gl3d/scene.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ proto.render = function() {
307307
// update size of svg container
308308
var svgContainer = scene.svgContainer;
309309
var clientRect = scene.container.getBoundingClientRect();
310-
var scaleX = gd._fullLayout._inverseScaleX;
311-
var scaleY = gd._fullLayout._inverseScaleY;
310+
var scaleX = gd._fullLayout._invScaleX;
311+
var scaleY = gd._fullLayout._invScaleY;
312312
var width = clientRect.width * scaleX;
313313
var height = clientRect.height * scaleY;
314314
svgContainer.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);

src/plots/polar/polar.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,9 @@ proto.updateMainDrag = function(fullLayout) {
944944

945945
var bbox = mainDrag.getBoundingClientRect();
946946
gd._fullLayout._calcInverseTransform(gd);
947-
var inverse = gd._fullLayout._inverseTransform;
948-
scaleX = gd._fullLayout._inverseScaleX;
949-
scaleY = gd._fullLayout._inverseScaleY;
947+
var inverse = gd._fullLayout._invTransform;
948+
scaleX = gd._fullLayout._invScaleX;
949+
scaleY = gd._fullLayout._invScaleY;
950950
var transformedCoords = Lib.apply3DTransform(inverse)(startX - bbox.left, startY - bbox.top);
951951
x0 = transformedCoords[0];
952952
y0 = transformedCoords[1];
@@ -1201,8 +1201,8 @@ proto.updateAngularDrag = function(fullLayout) {
12011201
var fullLayoutNow = _this.gd._fullLayout;
12021202
var polarLayoutNow = fullLayoutNow[_this.id];
12031203

1204-
var x1 = x0 + dx * fullLayout._inverseScaleX;
1205-
var y1 = y0 + dy * fullLayout._inverseScaleY;
1204+
var x1 = x0 + dx * fullLayout._invScaleX;
1205+
var y1 = y0 + dy * fullLayout._invScaleY;
12061206
var a1 = xy2a(x1, y1);
12071207
var da = rad2deg(a1 - a0);
12081208
rot1 = rot0 + da;
@@ -1297,7 +1297,7 @@ proto.updateAngularDrag = function(fullLayout) {
12971297
y0 = startY - bbox.top;
12981298

12991299
gd._fullLayout._calcInverseTransform(gd);
1300-
var transformedCoords = Lib.apply3DTransform(fullLayout._inverseTransform)(x0, y0);
1300+
var transformedCoords = Lib.apply3DTransform(fullLayout._invTransform)(x0, y0);
13011301
x0 = transformedCoords[0];
13021302
y0 = transformedCoords[1];
13031303

src/plots/ternary/ternary.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ proto.initInteractions = function() {
523523
_this.dragOptions.xaxes = [_this.xaxis];
524524
_this.dragOptions.yaxes = [_this.yaxis];
525525

526-
scaleX = gd._fullLayout._inverseScaleX;
527-
scaleY = gd._fullLayout._inverseScaleY;
526+
scaleX = gd._fullLayout._invScaleX;
527+
scaleY = gd._fullLayout._invScaleY;
528528

529529
var dragModeNow = _this.dragOptions.dragmode = gd._fullLayout.dragmode;
530530

@@ -579,7 +579,7 @@ proto.initInteractions = function() {
579579

580580
function zoomPrep(e, startX, startY) {
581581
var dragBBox = dragger.getBoundingClientRect();
582-
var inverse = gd._fullLayout._inverseTransform;
582+
var inverse = gd._fullLayout._invTransform;
583583
x0 = startX - dragBBox.left;
584584
y0 = startY - dragBBox.top;
585585
gd._fullLayout._calcInverseTransform(gd);

src/traces/parcats/parcats.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ function emitPointsEventColorHovermode(bandElement, eventName, event) {
767767
*
768768
*/
769769
function createHoverLabelForCategoryHovermode(gd, rootBBox, bandElement) {
770-
var scaleX = gd._fullLayout._inverseScaleX;
771-
var scaleY = gd._fullLayout._inverseScaleY;
770+
var scaleX = gd._fullLayout._invScaleX;
771+
var scaleY = gd._fullLayout._invScaleY;
772772

773773
// Selections
774774
var rectSelection = d3.select(bandElement.parentNode).select('rect.catrect');
@@ -871,8 +871,8 @@ function createHoverLabelForDimensionHovermode(gd, rootBBox, bandElement) {
871871
*
872872
*/
873873
function createHoverLabelForColorHovermode(gd, rootBBox, bandElement) {
874-
var scaleX = gd._fullLayout._inverseScaleX;
875-
var scaleY = gd._fullLayout._inverseScaleY;
874+
var scaleX = gd._fullLayout._invScaleX;
875+
var scaleY = gd._fullLayout._invScaleY;
876876

877877
var bandBoundingBox = bandElement.getBoundingClientRect();
878878

src/traces/sankey/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ module.exports = function plot(gd, calcData) {
292292
var hovertemplateLabels = {valueLabel: d3.format(d.valueFormat)(d.node.value) + d.valueSuffix};
293293
d.node.fullData = d.node.trace;
294294

295-
var scaleX = gd._fullLayout._inverseScaleX;
296-
var scaleY = gd._fullLayout._inverseScaleY;
295+
var scaleX = gd._fullLayout._invScaleX;
296+
var scaleY = gd._fullLayout._invScaleY;
297297

298298
var tooltip = Fx.loneHover({
299299
x0: scaleX * hoverCenterX0,

test/jasmine/tests/cartesian_interact_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,8 +2506,8 @@ describe('Cartesian plots with css transforms', function() {
25062506
// asserts that the zoombox path must go from the start to end positions,
25072507
// in css-transformed coordinates.
25082508
function _assertTransformedZoombox(startPos, endPos) {
2509-
startPos = Lib.apply3DTransform(gd._fullLayout._inverseTransform)(startPos[0], startPos[1]);
2510-
endPos = Lib.apply3DTransform(gd._fullLayout._inverseTransform)(endPos[0], endPos[1]);
2509+
startPos = Lib.apply3DTransform(gd._fullLayout._invTransform)(startPos[0], startPos[1]);
2510+
endPos = Lib.apply3DTransform(gd._fullLayout._invTransform)(endPos[0], endPos[1]);
25112511
var size = [endPos[0] - startPos[0], endPos[1] - startPos[1]];
25122512
var zb = d3.select(gd).select('g.zoomlayer > path.zoombox');
25132513
var zoomboxRect = _getZoomlayerPathRect(zb.attr('d'));

0 commit comments

Comments
 (0)