Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(widgets): ZoomWidget: Prevent crash when used with OrthographicView #9459

Merged
merged 2 commits into from
Feb 23, 2025

Conversation

ibgreen
Copy link
Collaborator

@ibgreen ibgreen commented Feb 23, 2025

Closes #

Background

  • FlyToInterpolator doesn't support orthographic viewports
  • This is a quick fix to unbreak
  • The ideal solution would presumably be to fix FlyToInterpolator to support more viewports

Change List

  • Avoid adding FlyToInterpolator if latitude is not present in view state.

@ibgreen ibgreen requested a review from chrisgervang February 23, 2025 12:25
Copy link
Collaborator

@chrisgervang chrisgervang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fly-to algo has ties to mercator polar math (e.g. non-linear zoom, great circle pathing) and could be a nice effect in cartesian views.

LinearInterpolator works with all views.

A nice easing should be relatively simple to add in interpolator, but we currently don't ship one. It'd been left to the user to write one themselves.. we provide the extendable interface, but haven't felt compelled to maintain an easing library in the core.

I'd say, if fly-to isn't easy to patch for non-geo then we have a compelling reason to add simple eased interpolator compatible with all views (or add a easing prop to the linear one.. something like that).

Transitions without easing or interpolation are rough..

@@ -117,14 +117,15 @@ export class ZoomWidget implements Widget<ZoomWidgetProps> {

handleZoom(viewport: Viewport, nextZoom: number) {
const viewId = this.viewId || viewport?.id || 'default-view';
const nextViewState = {
const nextViewState: Record<string, unknown> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had a generic view state type to use for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had a generic view state type to use for this

I couldn't figure it out. It is a complex thing to type, it is heavily overloaded and was designed before we introduced types.

@ibgreen
Copy link
Collaborator Author

ibgreen commented Feb 23, 2025

The fly-to algo has ties to mercator polar math (e.g. non-linear zoom, great circle pathing) and could be a nice effect in cartesian views.

LinearInterpolator works with all views.

A nice easing should be relatively simple to add in interpolator, but we currently don't ship one. It'd been left to the user to write one themselves.. we provide the extendable interface, but haven't felt compelled to maintain an easing library in the core.

I'd say, if fly-to isn't easy to patch for non-geo then we have a compelling reason to add simple eased interpolator compatible with all views (or add a easing prop to the linear one.. something like that).

Transitions without easing or interpolation are rough..

Sounds reasonable! As hubble creator, you are best positioned to determine what the right approach here. For now I changed the PR to switch to LinearInterpolator if non-geo, and allow interpolator to be disabled by setting transtionDuration to 0. That should unblock me.

@coveralls
Copy link

Coverage Status

coverage: 91.55%. remained the same
when pulling 00d45df on ib/fix-orthographic-zoom
into 16e5966 on master.

@ibgreen ibgreen merged commit c4ef912 into master Feb 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants