Package zebkit.web

Web specific stuff to provide abstracted method to work in WEB context.

protected <CanvasRenderingContext2D> $canvas (c, w, h, [forceResize])

Adjusts the given HTML Canvas element to the required size that takes in account device DPI. Extend the canvas 2D context with extra methods and variables that are used with zebkit UI engine.

  • c <HTMLCanvasElement>

    a HTML canvas element

  • w <Integer>

    a required width of the given canvas

  • h <Integer>

    a required height of the given canvas

  • [forceResize] <Boolean>

    flag to force canvas resizing even if the canvas has identical width and height. It is required to re-create canvas 2D context to work properly.

Returns: <CanvasRenderingContext2D>

a 2D context of the canvas element

private <Boolean> $contains (element)

Tests if the given DOM element is in document

Returns: <Boolean>

true if the given DOM element is in document

protected <HTMLElement> $createBlockedElement ( )

Creates HTML element that "eats" (doesn't propagate and prevents default) all input (touch, mouse, key) events that it gets.

Returns: <HTMLElement>

a created HTML element.

private void $extendContext (ctx, methods)

Extend standard 2D HTML Canvas context instance with the given set of methods. If new methods clash with already existent 2D context method the old one is overwritten with new one and old method is saved using its name prefixed with "$" character

private <Boolean> $isInsideElement (element, pageX, pageY)

Test if the given page coordinates is inside the given element

  • element <Element>

    a DOM element

  • pageX <Number>

    an x page coordinate

  • pageY <Number>

    an y page coordinate

Returns: <Boolean>

true if the given point is inside the specified DOM element

private <Object> $viewPortSize ( )

Calculates view port of a browser window

Returns: <Object>

a browser window view port size.

  width : {Integer},
  height: {Integer}

private <Number> $deviceRatio

Device ratio.