Nutrient Web SDK

Class Inset

An inset describes a rectangle by enumerating the distance from each side to the corresponding side of a reference rectangle. Therefore it does not hold coordinates, nor dimensions, only relative values for left, top, right and bottom. Provided values are defined in same units used by the page, point units. Point units are only equal to pixels when zoom value is 1.

It is an Immutable.Record and thus can be updated using set(key, value), for example: inset.set("right", 15).

Class

Example

Create and update an inset.

const inset = new NutrientViewer.Geometry.Inset({
left: 5,
top: 15,
right: 10,
bottom: 5
});
inset = inset.set("bottom", 7);
rect.bottom; // => 7

Default Value

{ left: 0, top: 0, right: 0, bottom: 0 }

Hierarchy

Readonly__dangerousImmutableRecordFactoryInset

Constructors

  • Parameters

    options{ bottom?: number; left?: number; right?: number; top?: number }
    Optional

Properties

bottom

Readonly
number

The bottom distance of the inset.

Default Value

0

left

Readonly
number

The left distance of the inset. This is equivalent to x of a NutrientViewer.Geometry.Point.

Default Value

0

top

Readonly
number

The top distance of the inset. This is equivalent to y of a NutrientViewer.Geometry.Point.

Default Value

0

Methods

fromValue

Static
  • Returns a new inset using the provided vale for all properties.

    Parameters

    insetValuenumber

    An inset value to be applied to all the properties.

    Returns

    Example

    const inset = NutrientViewer.Geometry.Inset.fromValue(10);
    // inset ->
    // {
    // left: 10,
    // top: 10,
    // right: 10,
    // bottom: 10,
    // }

Immutable Record API

24

asImmutable

Deprecated
  • Deprecated

    Returns

    this

    Deprecated

    Not part of the collection API the Nutrient Web SDK supports. Build the value once, or use withMutations().

    See Also

    • Map#asImmutable

asMutable

Deprecated
  • Deprecated

    Returns

    this

    Deprecated

    Not part of the collection API the Nutrient Web SDK supports. Use withMutations().

    See Also

    • Map#asMutable

  • Returns a new instance of this Record type with all values set to their default values.

    Returns

    this
  • Returns a new instance of this Record type with the value for the specific key set to its default value.

    Type Parameters

    Kextends "left" | "right" | "top" | "bottom"

    Parameters

    keyK

    Returns

    this
  • Returns a new instance of this Record type with the value at the given key path removed.

    Also available as removeIn.

    Parameters

    keyPathIterable<unknown>

    Returns

    this
  • Parameters

    otherunknown

    Returns

    boolean
  • Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.

    If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.

    Type Parameters

    Kextends "left" | "right" | "top" | "bottom"

    Parameters

    keyK

    Returns

    { bottom: number; left: number; right: number; top: number }[K]
  • Parameters

    keyPathIterable<unknown>
    notSetValueunknown
    Optional

    Returns

    unknown
  • Parameters

    keyunknown

    Returns

    boolean
  • Parameters

    ...collectionsPartial<{ bottom: number; left: number; right: number; top: number }>[]

    Returns

    this
  • Parameters

    ...collections(
    | Iterable<[string, unknown], any, any>
    | Partial<{ bottom: number; left: number; right: number; top: number }>
    )[]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    ...collections(
    | Iterable<[string, unknown], any, any>
    | Partial<{ bottom: number; left: number; right: number; top: number }>
    )[]

    Returns

    this
  • Parameters

    merger(previous?: unknown, next?: unknown, key?: string) => unknown
    ...collections(
    | Iterable<[string, unknown], any, any>
    | Partial<{ bottom: number; left: number; right: number; top: number }>
    )[]

    Returns

    this

mergeIn

Deprecated
  • Deprecated

    Parameters

    keyPathIterable<unknown>
    ...collections(
    | Iterable<[string, unknown], any, any>
    | Partial<{ bottom: number; left: number; right: number; top: number }>
    )[]

    Returns

    this

    Deprecated

    Not part of the collection API the Nutrient Web SDK supports. Use update() followed by merge().

  • Parameters

    merger(previous?: unknown, next?: unknown, key?: string) => unknown
    ...collections(
    | Iterable<[string, unknown], any, any>
    | Partial<{ bottom: number; left: number; right: number; top: number }>
    )[]

    Returns

    this

removeIn

Deprecated
  • Deprecated

    Parameters

    keyPathIterable<unknown>

    Returns

    this

    Deprecated

    Not part of the collection API the Nutrient Web SDK supports. Use deleteIn(), or update() followed by delete().

  • Type Parameters

    Kextends "left" | "right" | "top" | "bottom"

    Parameters

    keyK
    value{ bottom: number; left: number; right: number; top: number }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    valueunknown

    Returns

    this
  • Deeply converts this Record to equivalent native JavaScript Object.

    Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.

    Returns

    { bottom: number; left: number; right: number; top: number }
    • bottom: number

      The bottom distance of the inset.

      Default Value

      0
    • left: number

      The left distance of the inset. This is equivalent to x of a NutrientViewer.Geometry.Point.

      Default Value

      0
    • right: number

      The right distance of the inset.

      Default Value

      0
    • top: number

      The top distance of the inset. This is equivalent to y of a NutrientViewer.Geometry.Point.

      Default Value

      0
  • Shallowly converts this Record to equivalent native JavaScript Object.

    Returns

    { bottom: number; left: number; right: number; top: number }
    • bottom: number

      The bottom distance of the inset.

      Default Value

      0
    • left: number

      The left distance of the inset. This is equivalent to x of a NutrientViewer.Geometry.Point.

      Default Value

      0
    • right: number

      The right distance of the inset.

      Default Value

      0
    • top: number

      The top distance of the inset. This is equivalent to y of a NutrientViewer.Geometry.Point.

      Default Value

      0

toSeq

Deprecated
  • Deprecated

    Returns

    Keyed<string, unknown>

    Deprecated

    Not part of the collection API the Nutrient Web SDK supports. Use entries().

  • Type Parameters

    Kextends "left" | "right" | "top" | "bottom"

    Parameters

    keyK
    updater(
    value: { bottom: number; left: number; right: number; top: number }[K]
    ) => { bottom: number; left: number; right: number; top: number }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    notSetValueunknown
    updater(value: unknown) => unknown

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    updater(value: unknown) => unknown

    Returns

    this
  • Note: Not all methods can be used on a mutable collection or within withMutations! Only set may be used mutatively.

    Parameters

    mutator(mutable: this) => unknown

    Returns

    this

    See Also

    • Map#withMutations