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 ES5 syntax
  • Loading branch information
camdecoster committed Feb 21, 2025
commit 048f1786e5781208b4e118a27e8826482b3d71d3
16 changes: 8 additions & 8 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,19 +544,19 @@ function handleGeo(gd, ev) {
if(attr === 'zoom') {
var scale = geoLayout.projection.scale;
var minscale = geoLayout.projection.minscale;
var maxscale = geoLayout.projection.maxscale;

if(maxscale === -1) maxscale = Infinity;
var maxscale = geoLayout.projection.maxscale === -1 ? Infinity : geoLayout.projection.maxscale;
var max = Math.max(minscale, maxscale);
var min = Math.min(minscale, maxscale);
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;

// make sure the scale is within the min/max bounds
if(newScale > maxscale) {
newScale = maxscale;
} else if(newScale < minscale) {
newScale = minscale;
if (newScale > max) {
newScale = max;
} else if (newScale < min) {
newScale = min;
}

if(newScale !== scale) {
if (newScale !== scale) {
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ proto.updateFx = function(fullLayout, geoLayout) {

if(dragMode === 'pan') {
bgRect.node().onmousedown = null;
const zoom = createGeoZoom(_this, geoLayout)
var zoom = createGeoZoom(_this, 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
Expand Down Expand Up @@ -715,10 +715,10 @@ function getProjection(geoLayout) {

// https://d3js.org/d3-zoom#zoom_scaleExtent
projection.scaleExtent = () => {
let { minscale, maxscale } = projLayout;
maxscale = maxscale === -1 ? Infinity : maxscale;
const max = Math.max(minscale, maxscale);
const min = Math.min(minscale, maxscale);
var minscale = projLayout.minscale;
var maxscale = projLayout.maxscale === -1 ? Infinity : projLayout.maxscale;
var max = Math.max(minscale, maxscale);
var min = Math.min(minscale, maxscale);
return [100 * min, 100 * max];
};

Expand Down
20 changes: 10 additions & 10 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);

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

function handleZoom() {
const { bottom, left, right, top } = this.getBoundingClientRect()
var rect = this.getBoundingClientRect()
mouse1 = d3.event.sourceEvent
? d3.mouse(this)
: [(left + right) / 2, (bottom + top) / 2];
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 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);

const { bottom, left, right, top } = this.getBoundingClientRect()
let mouse0 = d3.event.sourceEvent
var rect = this.getBoundingClientRect()
var mouse0 = d3.event.sourceEvent
? d3.mouse(this)
: [(left + right) / 2, (bottom + top) / 2];
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 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() {
const { bottom, left, right, top } = this.getBoundingClientRect()
let mouse1 = d3.event.sourceEvent
var rect = this.getBoundingClientRect()
var mouse1 = d3.event.sourceEvent
? d3.mouse(this)
: [(left + right) / 2, (bottom + top) / 2];
: [(rect.left + rect.right) / 2, (rect.bottom + rect.top) / 2];

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

Expand Down