Fix weird zoom wrapping issue

This commit is contained in:
Jamie Wong 2017-12-27 01:10:35 -05:00
parent 9fdcb8ed1d
commit 7da9a14c2c
2 changed files with 6 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import { Flamechart } from './flamechart'
import * as regl from 'regl'
import { vec3, ReglCommand, ReglCommandConstructor } from 'regl'
import { Rect, Vec2, AffineTransform } from './math'
import { Rect, Vec2, AffineTransform, clamp } from './math'
import { atMostOnceAFrame } from "./utils";
import { rectangleBatchRenderer, RectangleBatchRendererProps } from "./rectangle-batch-renderer"
import { FlamechartMinimapView } from "./flamechart-minimap-view"
@ -403,7 +403,6 @@ export class FlamechartPanZoomView extends ReloadableComponent<FlamechartPanZoom
const physicalCenter = this.logicalToPhysicalViewSpace().transformPosition(logicalViewSpaceCenter)
const configSpaceCenter = this.configSpaceToPhysicalViewSpace().inverseTransformPosition(physicalCenter)
if (!configSpaceCenter) return
if (multiplier < 1 && this.configSpaceViewportRect.width() <= this.minConfigSpaceViewportRectWidth()) {
@ -473,6 +472,8 @@ export class FlamechartPanZoomView extends ReloadableComponent<FlamechartPanZoom
multiplier = 1 + (ev.deltaY / 40)
}
multiplier = clamp(multiplier, 0.1, 10.0)
this.zoom(new Vec2(ev.offsetX, ev.offsetY), multiplier)
} else if (this.interactionLock !== 'zoom') {
this.pan(new Vec2(ev.deltaX, ev.deltaY))

View File

@ -161,7 +161,9 @@ export class Flamechart {
this.minFrameWidth = Infinity
for (let layer of this.layers) {
for (let frame of layer) {
this.minFrameWidth = Math.min(this.minFrameWidth, frame.end - frame.start)
const width = frame.end - frame.start
if (!width) continue
this.minFrameWidth = Math.min(this.minFrameWidth, width)
}
}
this.selectFrameColors(profile)