Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
this.zoomTransform = !this.currentProps.zoomable
? zoomIdentity
: event.transform;
const zooming = this.prevZoomTransform.k !== this.zoomTransform.k;
// if there is dragging along a 1d track, only allow panning
// along the axis of the track
if (!zooming) {
if (trackOrientation === '1d-horizontal') {
// horizontal tracks shouldn't allow movement in the y direction
// don't move along y axis
this.zoomTransform = zoomIdentity.translate(
this.zoomTransform.x, this.prevZoomTransform.y
).scale(this.zoomTransform.k);
} else if (trackOrientation === '1d-vertical') {
// vertical tracks shouldn't allow movement in the x axis
this.zoomTransform = zoomIdentity.translate(
this.prevZoomTransform.x, this.zoomTransform.y
).scale(this.zoomTransform.k);
}
this.element.__zoom = this.zoomTransform;
}
this.applyZoomTransform(true);
this.prevZoomTransform = this.zoomTransform;
this.props.pubSub.publish('app.zoom', event);
if (animateTime) {
let selection = this.elementSelection;
this.activeTransitions += 1;
if (!document.hidden) {
// only transition if the window is hidden
selection = selection
.transition()
.duration(animateTime);
}
selection.call(
this.zoomBehavior.transform,
zoomIdentity.translate(translateX, translateY).scale(k),
)
.on('end', () => {
setZoom();
this.activeTransitions -= 1;
});
} else {
setZoom();
}
return last;
}
if (animateTime) {
let selection = this.elementSelection;
this.activeTransitions += 1;
if (!document.hidden) {
// only transition if the window is hidden
selection = selection
.transition()
.duration(animateTime);
}
selection.call(
this.zoomBehavior.transform,
zoomIdentity.translate(translateX, translateY).scale(k),
)
.on('end', () => {
setZoom();
this.activeTransitions -= 1;
});
} else {
setZoom();
}
return last;
}
zoomTo(translate?, scale?, transitionDuration = 250) {
translate = translate || this._zoomTranslate;
scale = scale || this._zoomScale;
transitionDuration = transitionDuration === undefined ? this.zoomDuration() : transitionDuration;
this.element().transition().duration(transitionDuration)
.call(this._currZoom.transform, d3ZoomIdentity.translate(translate[0], translate[1]).scale(scale))
;
}
function setTransform(t2, duration, force) {
var t = projection.transform();
if (!force && t2.k === t.k && t2.x === t.x && t2.y === t.y) return false;
if (duration) {
_selection
.transition()
.duration(duration)
.on('start', function() { map.startEase(); })
.call(zoom.transform, d3_zoomIdentity.translate(t2.x, t2.y).scale(t2.k));
} else {
projection.transform(t2);
_transformStart = t2;
_selection.call(zoom.transform, _transformStart);
}
return true;
}
projection.transform = function(obj) {
if (!arguments.length) return d3_zoomIdentity.translate(_x, _y).scale(_k);
_x = +obj.x;
_y = +obj.y;
_k = +obj.k;
return projection;
};
return state.update('transformToApply', () =>
zoomIdentity
.translate(state.get('transform').x, state.get('transform').y)
.scale(state.get('transform').k)
.scale(1 / state.get('transform').k)
.translate(
-(state.get('transform').x + action.x),
-(state.get('transform').y + action.y),
),
);
private setZoomTransform() {
if (!this.zoomBahavior) {
return;
}
select(this.$refs.svg as SVGSVGElement)
.call(this.zoomBahavior.transform,
zoomIdentity.translate(this.zoomTranslate[0], this.zoomTranslate[1]).scale(this.zoomScale));
}