Skip to content

Zoom Pulse Mode #40

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

Merged
merged 1 commit into from
Oct 27, 2017
Merged

Zoom Pulse Mode #40

merged 1 commit into from
Oct 27, 2017

Conversation

mbebenita
Copy link
Contributor

Depends on #38

This PR adds a Zoom Pulse button to slowly zoom in and out the Text and SVG demo. The goal is to demonstrate how smooth rendering is.

image

@mbebenita
Copy link
Contributor Author

I should mention that I couldn't find a good place to clear the setInterval, so the timer will keep going after the demo is unmounted. I'm not familiar with this UI toolkit, ... so ideas welcome.

@trishume
Copy link
Contributor

This has the risk of the zooming looking choppy even if the underlying rendering isn't, because of the timer being de-synchronized from the frames. Probably better to use requestAnimationFrame for the animation, this may also solve your issue with unregistering the timer.

}
let c = 0;
let d = 0.005;
this.pulseTimer = window.setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use requestAnimationFrame()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

@@ -306,6 +311,10 @@ export class PerspectiveCamera extends Camera {
]);
}

zoom(scale: number): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep the old zoom function private, but I needed something public that only took the scale argument. So I renamed the private function to _zoom and exposed the new function as zoom.

@mbebenita
Copy link
Contributor Author

@trishume good idea, I switched to RAFs in the latest patch.

@pcwalton
Copy link
Contributor

Works for me.

@pcwalton pcwalton merged commit 591e6b7 into servo:master Oct 27, 2017
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