API Docs for: 6.0.1
Show:

window.scrawl_Animation Class

window.scrawl

scrawlAnimation extension adaptions to the Scrawl library object

New library sections

  • scrawl.tween - for Tween and Action objects

New default attributes

  • Position.delta - default: {x:0,y:0,z:0};
  • Position.deltaPathPlace - default: 0;
  • Position.pathSpeedConstant - default: true;
  • Position.tweenLock - default: false;

  • Cell.sourceDelta - default: {x:0, y:0, z:0};

  • Cell.sourceMinWidth - default: 0;
  • Cell.sourceMaxWidth - default: 0;
  • Cell.sourceMinHeight - default: 0;
  • Cell.sourceMaxHeight - default: 0;

  • PageElement.tweenLock - default: false;

  • Design.roll - default: 0;

  • Design.autoUpdate - default: false;

Methods

addWithinBounds

(
  • a
  • b
)

A utility function that adds two numbers between 0 and 1, keeping them within bounds

Parameters:

  • a Number

    first number

  • b Number

    second number

Returns:

result of calculation

animationCellGet

() private

Cell.get hook function - modified by animation module

animationCellInit

() private

Cell constructor hook function

Adds a sourceDelta (sourceDeltaX, sourceDeltaY) Vector to the cell, used to give it a 'velocity'

animationCellSet

() private

Cell.set hook function - modified by animation module

animationPositionClone

() private

Position.clone hook function - modified by animation module

animationPositionGet

() private

Position.get hook function - modified by animation module

animationPositionInit

() private

Position constructor hook function

Adds a delta (deltaX, deltaY) Vector to the object, used to give an object a 'velocity'

animationPositionSet

() private

Position.set hook function - modified by animation module

Cell.revertStart

(
  • [item]
)
chainable

Subtracts delta values from the start vector; subtracts sourceDelta values from the source vector; subtracts deltaPathPlace to pathPlace

Permitted argument values include

  • 'x' - delta.x subtracted from start.x; deltaSource.x subtracted from source.x
  • 'y' - delta.y subtracted from start.y; deltaSource.y subtracted from source.y
  • 'start', 'target' - delta subtracted from start
  • 'source' - deltaSource subtracted from source
  • 'path' - deltaPathPlace subtracted from pathPlace
  • undefined: all values are amended

Parameters:

  • [item] String optional

    String used to limit this function's actions

Returns:

This

Cell.revertStartActions

() private

revertStart helper object

Cell.spliceCell

(
  • items
)
chainable

Perform a splice-shift-join operation on the <canvas> element's current scene

Argument is an Object in the form:

  • {edge:String, strip:Number}

Permitted values for the argument Object's attributes are:

  • edge - one from 'horizontal', 'vertical', 'top', 'bottom', 'left', 'right'
  • strip - a width/height Number (in pixels) of the strip that is to be moved from the named edge of the <canvas> to the opposite edge
  • shiftSource - boolean - when true, will automatically shift the sourceX and sourceY coordinates; default: false

Note that this function is only effective in achieving a parallax effect if the user never clears or updates the cell's <canvas> element, and takes steps to shift the cell's source vector appropriately each time the splice operation is performed

Parameters:

  • items Object

    Object containing data for the splice operation

Returns:

This

Cell.updateStart

(
  • [item]
)
chainable

Adds delta values to the start vector; adds sourceDelta values to the source vector; adds deltaPathPlace to pathPlace

Permitted argument values include

  • 'x' - delta.x added to start.x; deltaSource.x added to source.x
  • 'y' - delta.y added to start.y; deltaSource.y added to source.y
  • 'start', 'target' - delta added to start
  • 'source' - deltaSource added to source
  • 'path' - deltaPathPlace added to pathPlace
  • undefined: all values are amended

Parameters:

  • [item] String optional

    String used to limit this function's actions

Returns:

This

Cell.updateStartActions

() private

updateStart helper object

Cell.zoom

(
  • item
)
chainable

Zooms one cell in relation to another cell

Parameters:

  • item Number

    Number of pixels to amend the zoomed cell's start and dimensions by

Returns:

This

convertTime

() private

Convert a time into its component properties

Expected values:

  • Number - time value in milliseconds
  • String number+% - will always return a Number time value of 0
  • String number+ms - returns a Number time value in milliseconds
  • String number+s - converts and returns a Number time value in milliseconds

Returns:

[String timeUnit, Number timeValue]

Design.sortStops

() private

Gradient builder helper function - sorts color attribute Objects by their stop attribute values, after adding the roll value to them

Returns:

Nothing

Design.update

(
  • [entity]
  • [cell]
)
chainable

Creates the gradient

This function replaces the one in the core module

Parameters:

  • [entity] String optional

    SPRITENAME String

  • [cell] String optional

    CELLNAME String

Returns:

This

Group.reverse

(
  • [item]
)
chainable

Ask all entitys in the group to perform a reverse() operation

Each entity will change the sign (+/-) of specified attribute values

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'deltaX', 'deltaY', 'delta', 'deltaPathPlace'; default action: all values are amended

Returns:

This

Group.revertStart

(
  • [item]
)
chainable

Ask all entitys in the Group to perform a revertStart() operation

Each entity will subtract their delta values to their start Vector, and/or subtract deltaPathPlace from pathPlace

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'x', 'y', 'path'; default action: all values are amended

Returns:

This

Group.updateStart

(
  • [item]
)
chainable

Ask all entitys in the Group to perform an updateStart() operation

Each entity will add their delta values to their start Vector, and/or add deltaPathPlace from pathPlace

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'x', 'y', 'path'; default action: all values are amended

Returns:

This

locateTarget

(
  • OBJECTNAME
)
private

Locate a target object

Parameters:

  • OBJECTNAME String

    string of required target

Returns:

target Object; false if not found

makeAction

(
  • items
)

A factory function to generate new Action objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Action object

makeTicker

(
  • items
)

A factory function to generate new Ticker objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Ticker object

makeTween

(
  • items
)

A factory function to generate new Tween objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Tween object

newAction

() deprecated

Alias for makeAction()

newTween

() deprecated

Alias for makeTween()

Position.exchange

(
  • obj
  • item
)
chainable

Swaps the values of an attribute between two objects

Parameters:

  • obj Object

    Object with which this object will swap attribute values

  • item String

    Attribute to be swapped

Returns:

This

Position.reverse

(
  • [item]
)
chainable

Changes the sign (+/-) of specified attribute values

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'deltaX', 'deltaY', 'delta', 'deltaPathPlace'; default action: all values are amended

Returns:

This

Position.reverseActions

() private

reverse helper object

Position.revertStart

(
  • [item]
)
chainable

Subtracts delta values from the start vector; subtracts deltaPathPlace from pathPlace

Permitted argument values include

  • 'x' - delta.x subtracted from start.x
  • 'y' - delta.y subtracted from start.y
  • 'path' - deltaPathPlace subtracted from pathPlace
  • undefined: all values are amended

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'x', 'y', 'path'; default action: all values are amended

Returns:

This

Position.revertStartActions

() private

revertStart helper object

Position.updateStart

(
  • [item]
)
chainable

Adds delta values to the start vector; adds deltaPathPlace to pathPlace

Permitted argument values include

  • 'x' - delta.x added to start.x
  • 'y' - delta.y added to start.y
  • 'path' - deltaPathPlace added to pathPlace
  • undefined: all values are amended

Parameters:

  • [item] String optional

    String used to limit this function's actions - permitted values include 'x', 'y', 'path'; default action: all values are amended

Returns:

This

Position.updateStartActions

() private

updateStart helper object

setDeltaAttribute

(
  • items
)
chainable

Augments Position.set(), to allow users to set the delta attributes using delta, deltaX, deltaY

The scrawlAnimation module adds a delta attribute to Cells and Entitys - this is an inbuilt delta vector which can be used to automatically animate the start vector of these objects - via the updateStart, revertStart and reverse functions - as part of the animation cycle.

Be aware that this is different to the Position.setDelta() function inherited by Cells and Entitys. setDelta is used to add a supplied argument value to the existing values of any numerical attribute of a Cell or Entity object, and is thus not limited to the animation cycle.

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

Properties

autoUpdate

Boolean

A flag to indicate that stop color shifts should be automatically applied

Default: false

shift

Number

A value for shifting the color stops (was roll in versions prior to v4.0)

Default: 0