@itwin/core-frontend
Version:
iTwin.js frontend components
37 lines • 1.75 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Views
*/
import { Geometry } from "@itwin/core-geometry";
/** Specifies margins to apply around a view volume for methods like [[ViewState.lookAtVolume]] and [[Viewport.zoomToElements]], expanding the
* viewed volume by a percentage of its original size to add extra space around one or more edges.
* The margin values represent a fraction of the view volume's width (for [[left]] and [[right]]) or height (for [[top]] and [[bottom]]).
* The values are clamped to the range 0 through 0.25.
* @note Margins are only applied in 2d views, or 3d views in which the camera has been turned off.
* @note The way in which the extra space is computed is somewhat unintuitive and may lead to surprising results.
* @see [[MarginOptions.marginPercent]].
* @see [[PaddingPercent]] for a more predictable way of adjusting the viewed volume.
* @public
* @extensions
*/
export class MarginPercent {
left;
top;
right;
bottom;
constructor(left, top, right, bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
const limitMargin = (val) => Geometry.clamp(val, 0.0, 0.25);
this.left = limitMargin(left);
this.top = limitMargin(top);
this.right = limitMargin(right);
this.bottom = limitMargin(bottom);
}
}
//# sourceMappingURL=MarginPercent.js.map