MCPcopy Index your code
hub / github.com/microsoft/SandDance / flyToViewport

Function flyToViewport

docs/app/js/sanddance-app.js:80664–80688  ·  view source on GitHub ↗
(startProps, endProps, t, options)

Source from the content-addressed store, hash-verified

80662 speed: 1.2
80663};
80664function flyToViewport(startProps, endProps, t, options) {
80665 const { startZoom , startCenterXY , uDelta , w0 , u1 , S , rho , rho2 , r0 } = getFlyToTransitionParams(startProps, endProps, options);
80666 if (u1 < EPSILON) {
80667 const viewport = {};
80668 for (const key of VIEWPORT_TRANSITION_PROPS){
80669 const startValue = startProps[key];
80670 const endValue = endProps[key];
80671 viewport[key] = (0, _mathUtils.lerp)(startValue, endValue, t);
80672 }
80673 return viewport;
80674 }
80675 const s = t * S;
80676 const w = Math.cosh(r0) / Math.cosh(r0 + rho * s);
80677 const u = w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2) / u1;
80678 const scaleIncrement = 1 / w;
80679 const newZoom = startZoom + (0, _webMercatorUtils.scaleToZoom)(scaleIncrement);
80680 const newCenterWorld = _vec2.scale([], uDelta, u);
80681 _vec2.add(newCenterWorld, newCenterWorld, startCenterXY);
80682 const newCenter = (0, _webMercatorUtils.worldToLngLat)(newCenterWorld);
80683 return {
80684 longitude: newCenter[0],
80685 latitude: newCenter[1],
80686 zoom: newZoom
80687 };
80688}
80689exports.default = flyToViewport;
80690function getFlyToDuration(startProps, endProps, options) {
80691 const opts = {

Callers

nothing calls this directly

Calls 3

getFlyToTransitionParamsFunction · 0.70
scaleMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected