API Docs for: 6.0.1
Show:

Device Class

Extends Base
Module: scrawlCore

Device

Instantiation

  • This object should never be instantiated by users

Purpose

  • Wraps the browser's viewport, and includes basic information about the device

Constructor

Device

()

Methods

checkCanvas

() private

Check if device supports canvas element

checkCanvasDashedLine

() private

Check if device supports dashed line functionality

checkCanvasEvenOddWinding

() private

Check if device supports canvas evenOdd winding

checkCanvasGco

() private

Check if device supports various global composition operation functionalities

checkTouch

() private

Check if we should expect to receive touch events

Modern IE uses pointer events, so Device will not check for IE specific touch-enabled devices

clone

(
  • items
)
chainable

Clone a Scrawl.js object, optionally altering attribute values in the cloned object

Note that any callback or fn attribute functions will be referenced by the clone, not copied to the clone; these can be overwritten with new anonymous functions by including them in the items argument object

(This function is replaced by the path extension)

Parameters:

  • items Object

    Object containing attribute key:value pairs; will overwrite existing values in the cloned, but not the source, Object

Returns:

Cloned object

Example:

var box = scrawl.makeBlock({
    width: 50,
    height: 50
    });
var newBox = box.clone({
    height: 100
    });
newBox.get('width');        //returns 50
newBox.get('height');       //returns 100

get

(
  • item
)

Retrieve an attribute value. If the attribute value has not been set, then the default value for that attribute will be returned.

Parameters:

  • item String

    Attribute key

Returns:

Attribute value

Example:

var box = scrawl.makeBlock({
    width: 50,
    });
box.get('width');               //returns 50
box.get('height');              //returns 0
box.get('favouriteAnimal');     //returns undefined

getDeviceData

() private

Feature detection

getImagesDeviceData

() private

Feature detection - hook function

getStacksDeviceData

() private

Feature detection - hook function

getViewportDimensions

() private

Determine viewport dimensions

Returns:

Boolean - true if dimensions have changed; false otherwise

getViewportPosition

() private

Determine viewport position within the page

Returns:

Boolean - true if scrolling has occurred; false otherwise

isLandscape

() private

Determine if viewport is in landscape mode - if width and height arte equal, landscape mode is assumend

isPortrait

() private

Determine if viewport is in portrait mode - if width and height arte equal, landscape mode is assumend

numberConvert

(
  • val
  • dim
)
private

Stamp helper function - convert string percentage values to numerical values

Parameters:

  • val String

    coordinate String

  • dim Number

    dimension value

Returns:

Number - value

parse

()

Turn the object into a JSON String

Returns:

object of object's currently set attributes

set

(
  • items
)
chainable

Set attribute values. Multiple attributes can be set in the one call by including the attribute key:value pair in the argument object.

An attribute value will only be set if the object already has a default value for that attribute. This restricts the ability of coders to add attributes to Scrawl objects.

Parameters:

  • items Object

    Object containing attribute key:value pairs

Returns:

This

Example:

var box = scrawl.makeBlock({
    width: 50,
    height: 50
    });
box.set({
    height: 100,
    favouriteAnimal: 'cat'
    });
box.get('width');               //returns 50
box.get('height');              //returns 100
box.get('favouriteAnimal');     //returns undefined

Properties

canvas

Boolean

canvas support

False if device does not support the canvas element; true otherwise

Default: false

canvasDashedLine

Boolean

canvas dashed line functionality

False if device does not support the canvas dashed line functionality; true otherwise

Default: false

canvasEvenOddWinding

Boolean

canvas even-odd winding functionality

False if device does not support the canvas even-odd winding functionality; true otherwise

Default: false

canvasGcoCopy

Boolean

canvas global composite operation support: copy

False if device incorrectly supports the GCO copy functionality

Default: false

canvasGcoDestinationAtop

Boolean

canvas global composite operation support: destination-atop

False if device incorrectly supports the GCO destination-atop functionality

Default: false

canvasGcoDestinationIn

Boolean

canvas global composite operation support: destination-in

False if device incorrectly supports the GCO destination-in functionality

Default: false

canvasGcoSourceIn

Boolean

canvas global composite operation support: source-in

False if device incorrectly supports the GCO source-in functionality

Default: false

canvasGcoSourceOut

Boolean

canvas global composite operation support: source-out

False if device incorrectly supports the GCO source-out functionality

Default: false

comment

String

Comment, for accessibility

Default: ''

expectTouch

Number

Device/browser is touch-enabled and we should expect to receive touch events

Default: calculated automatically

height

Number

viewport height

Default: calculated automatically

name

String

Unique identifier for each object; default: computer-generated String based on Object's type

offsetX

Number

viewport offset from the top of the document

Default: calculated automatically

offsetY

Number

viewport offset from the left side of the document

Default: calculated automatically

timestamp

String

Creation timestamp

Default: ''

title

String

Title, for accessibility

Default: ''

type

String final

Inherited from Base but overwritten in source\scrawlCore.js:2638

Default: 'Device'

width

Number

viewport width

Default: calculated automatically