springroll.AssetSizes Class

Module: Core

Manages filtering of loads to load assets sized for the current device.

define

(
  • id
  • maxSize
  • scale
  • fallback
)

Defined in define:65

Adds a new size definition.

Parameters:

  • id String

    The name of the folder which contains assets of this size.

  • maxSize Int

    The maximum size in points capable of using this size.

  • scale Number

    The scale of assets

  • fallback Array

    The size fallbacks if this size isn't available for the current asset request.

destroy

()

Defined in destroy:182

Destroy and don't use after this

filter

(
  • url
  • [size]
)
String

Defined in filter:93

Update a URL by size

Parameters:

  • url String

    The asset to load

  • [size] Object optional

    The currrent size object

    • [id] Object optional

      The name of the current size

Returns:

String:

The formatted url

refresh

(
  • width
  • height
)
Object

Defined in refresh:154

Recalculate the current preferred size based on width and height

Parameters:

  • width Number

    The width of the stage

  • height Number

    The height of the stage

Returns:

Object:

The size

reset

()

Defined in reset:55

Removes all currently defined sizes.

size

(
  • [supported]
)
Object

Defined in size:118

Get a size based on the current asset sizes supported

Parameters:

  • [supported] Object optional

    Return the preferred size if nothing is set

Returns:

Object:

Return the size object with id, scale, maxSize and fallback keys

test

(
  • url
)
Boolean

Defined in test:107

Make sure we have a token

Parameters:

Returns:

Boolean:

If we have the token

_preferredSize

Object

Defined in _preferredSize:36

The preferred size

_sizes

Array private

Defined in _sizes:22

The collection of size objects

_sizesMap

_sizesMap private

Defined in _sizesMap:29

The map of size objects

SIZE_TOKEN

String static

Defined in SIZE_TOKEN:47

The URL substitution string.

Default: "%SIZE%"