@eclipse-scout/core
Version:
Eclipse Scout runtime
206 lines • 9.34 kB
TypeScript
/// <reference types="jquery" />
import { Dimension, Insets, Point, Rectangle } from '../index';
export interface PrefSizeOptions {
/**
* When set to true the returned dimensions may contain fractional digits, otherwise the sizes are rounded up. Default is false.
*/
exact?: boolean;
/**
* Whether to include the margins in the returned size. Default is false.
*/
includeMargin?: boolean;
/**
* If true, the width and height properties are set to '' while measuring, thus allowing existing CSS rules to influence the sizes.
* If set to false, the sizes are set to 'auto' or the corresponding hint values. Default is false.
*/
useCssSize?: boolean;
/**
* If useCssSize is false, this value is used as width (in pixels) instead of 'auto'.
* Useful to get the preferred height for a given width.
*/
widthHint?: number;
/**
* Same as 'widthHint' but for the height.
*/
heightHint?: number;
/**
* Sets min/max-width/height in addition to with width/height if widthHint resp. heightHint is set.
* The browser sometimes makes the element smaller or larger than specified by width/height, especially in a flex container.
* To prevent that, set this option to true. Default is false, but may change in the future.
*/
enforceSizeHints?: boolean;
/**
* By default, the $elem's scrolling position is saved and restored during the execution of this method (because applying
* intermediate styles for measurement might change the current position). If the calling method does that itself, you should
* set this option to false in order to prevent overriding the stored scrolling position in $elem's data attributes. Default is true.
*/
restoreScrollPositions?: boolean;
/**
* If set, the $elem is checked for one of these classes.
* If one of these classes is currently set on the $elem, a clone of the $elem without the classes is created and measured instead. See also {@link prefSizeWithoutAnimation}.
*/
animateClasses?: string[];
}
export interface SizeOptions {
/**
* When set to true the returned dimensions may contain fractional digits, otherwise the sizes are rounded up. Default is false.
*/
exact?: boolean;
/**
* Whether to include the margins in the returned size. Default is false.
*/
includeMargin?: boolean;
}
export interface InsetsOptions {
/**
* Whether to include the margins in the returned insets. Default is false.
*/
includeMargin?: boolean;
/**
* Whether to include the paddings in the returned insets. Default is true.
*/
includePadding?: boolean;
/**
* Whether to include the borders in the returned insets. Default is true.
*/
includeBorder?: boolean;
}
export interface BoundsOptions {
/**
* When set to true the returned size may contain fractional digits, otherwise the sizes are rounded up. X and Y are not affected by this option. Default is false.
*/
exact?: boolean;
/**
* Whether to include the margins in the returned size. X and Y are not affected by this option. Default is false.
*/
includeMargin?: boolean;
}
declare function setBounds($comp: JQuery, x: number, y: number, width: number, height: number): any;
declare function setBounds($comp: JQuery, bounds: Rectangle): any;
declare function setSize($comp: JQuery, width: number, height: number): any;
declare function setSize($comp: JQuery, size: Dimension): any;
declare function setLocation($comp: JQuery, x: number, y: number): any;
declare function setLocation($comp: JQuery, location: Point): any;
/**
* Helpers for graphical operations
*/
export declare const graphics: {
/**
* Returns the preferred size of $elem.
*
* Precondition: $elem and its parents must not be hidden ('display: none' - other styles like 'visibility: hidden'
* or 'opacity: 0' would be ok because in this case the browser reserves the space the element would be using).
*
* The `style` and `class` properties are temporarily altered to allow the element to assume its "natural size".
* A marker CSS class `measure` is added that can be used to reset element-specific CSS constraints (e.g. flexbox).
*
* @param $elem
* the jQuery element to measure
* @param options
* an optional options object. Shorthand version: If a boolean is passed instead
* of an object, the value is automatically converted to the option "includeMargin".
*/
prefSize($elem: JQuery, options?: PrefSizeOptions | boolean): Dimension;
/**
* Ensure resulting numbers are integers. getBoundingClientRect() might correctly return fractional values
* (because of the browser's sub-pixel rendering). However, if we use those numbers to set the size
* of an element using CSS, it gets rounded or cut off. The behavior is not defined amongst different
* browser engines.
* <p>
* Example:
* - Measured size from this method: h = 345.239990234375
* - Set the size to an element: $elem.css('height', h + 'px')
* - Results:
* Firefox & Chrome <div id="elem" style="height: 345.24px"> [Fractional part rounded to three digits]
*/
exactPrefSize(prefSize: Dimension, options: PrefSizeOptions): Dimension;
/**
* If the $elem is currently animated by CSS, create a clone, remove the animating CSS class and measure the clone instead.
* This may be necessary because the animation might change the size of the element.
* If prefSize is called during the animation, the current size is returned instead of the one after the animation.
*/
prefSizeWithoutAnimation($elem: JQuery, options: PrefSizeOptions): Dimension;
/**
* Returns the size of the element, insets included. The sizes are rounded up, unless the option 'exact' is set to true.
*
* @param $elem
* the jQuery element to measure
* @param options
* an optional options object. Shorthand version: If a boolean is passed instead
* of an object, the value is automatically converted to the option "includeMargin".
*/
size($elem: JQuery, options?: SizeOptions | boolean): Dimension;
/**
* @returns the size of the element specified by the style.
*/
cssSize($elem: JQuery): Dimension;
/**
* @returns the max size of the element specified by the style.
*/
cssMaxSize($elem: JQuery): Dimension;
/**
* @returns the min size of the element specified by the style.
*/
cssMinSize($elem: JQuery): Dimension;
setSize: typeof setSize;
/**
* Returns the inset-dimensions of the component (padding, margin, border).
*
* @param $elem
* the jQuery element to measure
* @param options
* an optional options object. Shorthand version: If a boolean is passed instead
* of an object, the value is automatically converted to the option {@link InsetsOptions.includeMargin}.
*/
insets($comp: JQuery, options?: InsetsOptions | boolean): Insets;
margins($comp: JQuery): Insets;
setMargins($comp: JQuery, margins: Insets): void;
paddings($comp: JQuery): Insets;
borders($comp: JQuery): Insets;
setLocation: typeof setLocation;
/**
* Returns a Point consisting of the component's "cssLeft" and
* "cssTop" values (reverse operation to setLocation).
*/
location($comp: JQuery): Point;
/**
* Returns the bounds of the element relative to the offset parent, insets included.
* The sizes are rounded up, unless the option 'exact' is set to true.
*
* @param $elem
* the jQuery element to measure
* @param options
* an optional options object. Shorthand version: If a boolean is passed instead
* of an object, the value is automatically converted to the option "includeMargin".
*/
bounds($elem: JQuery, options?: BoundsOptions | boolean): Rectangle;
/**
* @returns {Point} the position relative to the offset parent ($elem.position()).
*/
position($elem: JQuery): Point;
/**
* Returns the bounds of the element relative to the document, insets included.
* The sizes are rounded up, unless the option 'exact' is set to true.
*
* @param $elem
* the jQuery element to measure
* @param options
* an optional options object. Shorthand version: If a boolean is passed instead
* of an object, the value is automatically converted to the option "includeMargin".
*/
offsetBounds($elem: JQuery, options?: BoundsOptions | boolean): Rectangle;
/**
* @returns the position relative to the document, see also {@link JQuery.offset}.
*/
offset($elem: JQuery): Point;
/** @internal */
_bounds($elem: JQuery, pos: JQuery.Coordinates, options?: BoundsOptions | boolean): Rectangle;
setBounds: typeof setBounds;
/**
* @returns the bounds of the element specified by the style.
*/
cssBounds($elem: JQuery): Rectangle;
debugOutput($comp: JQuery | HTMLElement): string;
};
export {};
//# sourceMappingURL=graphics.d.ts.map