@devexperts/dxcharts-lite
Version:
64 lines (63 loc) • 2.93 kB
JavaScript
/*
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { CanvasElement } from '../../canvas/canvas-bounds-container';
import { ChartBaseElement } from '../../model/chart-base-element';
import { ChartAreaPanHandler } from '../chart/chart-area-pan.handler';
import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
import { isSafari } from '../../utils/device/touchpad.utils';
import { SafariChartAreaPanHandler } from '../../utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler';
export class ChartPanComponent extends ChartBaseElement {
constructor(eventBus, mainScale, canvasBoundsContainer, config, canvasAnimation, canvasInputListener, mainCanvasParent, chartBaseModel, hitTestCanvasModel) {
super();
this.eventBus = eventBus;
this.mainScale = mainScale;
this.canvasBoundsContainer = canvasBoundsContainer;
this.config = config;
this.canvasAnimation = canvasAnimation;
this.canvasInputListener = canvasInputListener;
this.mainCanvasParent = mainCanvasParent;
this.chartBaseModel = chartBaseModel;
this.hitTestCanvasModel = hitTestCanvasModel;
const chartAreaPanHandlerParams = [
this.eventBus,
this.config,
this.mainScale,
this.canvasInputListener,
this.canvasBoundsContainer,
this.canvasAnimation,
this,
this.hitTestCanvasModel,
];
// Different performance logic for Safari because of browser specifics
const chartAreaPanHandler = isSafari
? new SafariChartAreaPanHandler(...chartAreaPanHandlerParams)
: new ChartAreaPanHandler(...chartAreaPanHandlerParams);
this.chartAreaPanHandler = chartAreaPanHandler;
this.addChildEntity(this.chartAreaPanHandler);
this.mainCanvasTouchHandler = new MainCanvasTouchHandler(this.chartAreaPanHandler, this.mainScale, this.canvasInputListener, this.mainCanvasParent, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES));
this.addChildEntity(this.mainCanvasTouchHandler);
}
/**
* Activates user mouse handlers on main chart view.
* @function
* @name activateChartPanHandlers
* @memberof [object Object]
* @instance
* @returns {void}
*/
activateChartPanHandlers() {
this.activate();
}
/**
* Deactivates all the pan handlers of the chart.
*/
deactivatePanHandlers() {
this.deactivate();
}
setChartPanningOptions(horizontal, vertical) {
this.chartAreaPanHandler.chartPanningOptions = { horizontal, vertical };
}
}