Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/app/data_types_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,21 @@ export interface ZoomConfig {
max: number;
/** Buttons should increment or decrement by what magnitude. Default: .05 */
step: number;
/** Increment or decrement per scroll / trackpad delta. Default: .02 */
scrollStepPerDelta?: number;
}

/** Increment or decrement per scroll / trackpad delta. */
export const SCROLL_STEP_PER_DELTA = .02;

/** Default zoom config that can be used for DAG Toolbar or DAG Renderer */
export const defaultZoomConfig: ZoomConfig = {
max: 1.5,
min: .2,
step: .10,
scrollStepPerDelta: SCROLL_STEP_PER_DELTA,
};

/** Increment or decrement per scroll / trackpad delta. */
export const SCROLL_STEP_PER_DELTA = .02;

/**
* Allows you to construct a full DAG Zoom Config set from partial entries
* which override the defaults
Expand Down
6 changes: 3 additions & 3 deletions src/app/zooming_layer.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ export class ZoomingLayer implements OnInit, OnDestroy {
}

private zoomOnWheel($e: WheelEvent) {
const {min, max} = this.zoomStepConfig;
const {min, max, step, scrollStepPerDelta = SCROLL_STEP_PER_DELTA} = this.zoomStepConfig;
const invSign = $e.deltaY > 0 ? -1 : 1;
let newZoom = this.stateService.zoom.value +
invSign *
Math.min(
SCROLL_STEP_PER_DELTA * Math.abs($e.deltaY),
this.zoomStepConfig.step);
scrollStepPerDelta * Math.abs($e.deltaY),
step);
newZoom = clampVal(newZoom, min, max);

const container = this.dagWrapper.nativeElement.getBoundingClientRect();
Expand Down
Loading