Show:

Encapsulates a stream of size data (size, proportions, margins). Listens on start/update/end events, batches them, and emits resize events downstream to descendant size nodes.

Size can be defined with height and width given numerically, but they can also be:

    undefined - takes the parent value
    true      - takes the DOM calculated value
    false     - value defined by setting an aspect ratio

Constructor

Core.SizeNode

(
  • sources
)
private

Parameters:

  • sources Object

    Object of size sources

    • [size] Stream | Array optional

      Size source

    • [margin] Stream | Array optional

      Margin source

    • [proportions] Stream | Array optional

      Proportions source

    • [aspectRatio] Stream | Number optional

      Aspect ratio source

Example:

 var context = Context();
        
         var surface = new Surface({
             size : [100,100],
             properties : {background : 'red'}
         });
        
         var sizeNode = new SizeNode({
             size : [100, undefined],
             margins : [50, 50]
         });
        
         context.add(sizeNode).add(surface);
         context.mount(document.body)

Item Index

Methods

Methods

set

(
  • obj
)

Introduce new data streams to the size node in {key : value} pairs. Here the key is one of "size", "proportions" or "marins". The value is either a stream, or a simple type like a Number or Array. Simple types will be wrapped in an Observerable to emit appropriate events.

Parameters:

  • obj Object

    Object of data sources