Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch to getBBox and fix zoom.event call
  • Loading branch information
camdecoster committed Feb 22, 2025
commit 84cd037acf7138f9a6fa684626dc2acf6c57ec9c
2 changes: 1 addition & 1 deletion src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ proto.updateFx = function(fullLayout, geoLayout) {
bgRect.call(zoom);
// TODO: Figure out how to restrict when this transition occurs. Or is it a no-op if nothing has changed?
// Trigger transition to handle if minscale attribute isn't 0
zoom.event(bgRect.transition())
zoom.event(bgRect)
bgRect.on('dblclick.zoom', zoomReset);
if(!gd._context._scrollZoom.geo) {
bgRect.on('wheel.zoom', null);
Expand Down
16 changes: 8 additions & 8 deletions src/plots/geo/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ function zoomNonClipped(geo, projection) {
function handleZoomstart() {
d3.select(this).style(zoomstartStyle);

var rect = this.getBoundingClientRect()
var rect = this.getBBox()
mouse0 = d3.event.sourceEvent
? d3.mouse(this)
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 2];
: [rect.x + rect.width / 2, rect.y + rect.height / 2];
rotate0 = projection.rotate();
translate0 = projection.translate();
lastRotate = rotate0;
zoomPoint = position(mouse0);
}

function handleZoom() {
var rect = this.getBoundingClientRect()
var rect = this.getBBox()
mouse1 = d3.event.sourceEvent
? d3.mouse(this)
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 2];
: [rect.x + rect.width / 2, rect.y + rect.height / 2];
if(outside(mouse0)) {
zoom.scale(projection.scale());
zoom.translate(projection.translate());
Expand Down Expand Up @@ -216,10 +216,10 @@ function zoomClipped(geo, projection) {
zoom.on('zoomstart', function() {
d3.select(this).style(zoomstartStyle);

var rect = this.getBoundingClientRect()
var rect = this.getBBox()
var mouse0 = d3.event.sourceEvent
? d3.mouse(this)
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 2];
: [rect.x + rect.width / 2, rect.y + rect.height / 2];
var rotate0 = projection.rotate();
var lastRotate = rotate0;
var translate0 = projection.translate();
Expand All @@ -228,10 +228,10 @@ function zoomClipped(geo, projection) {
zoomPoint = position(projection, mouse0);

zoomOn.call(zoom, 'zoom', function() {
var rect = this.getBoundingClientRect()
var rect = this.getBBox()
var mouse1 = d3.event.sourceEvent
? d3.mouse(this)
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 2];
: [rect.x + rect.width / 2, rect.y + rect.height / 2];

projection.scale(view.k = d3.event.scale);

Expand Down