Class

Viewport

Viewport(x, y, scale) → {Viewport}

The viewport object is one of the basic objects beside, circle, rectangle and similar. You can use this to group elements together in a new viewport and new coordinates for every sub-component.

Constructor

# new Viewport(x, y, scale) → {Viewport}

Initiates the Viewport object

Parameters:
Name Type Default Description
x number

The x position of the viewport in the parent.

y number

The y position of the viewport in the parent.

scale number 1

This value is only used for scaling

View Source index.js, line 255

Viewport

Methods

# addComponent(c, render) → {void}

Add a component to the viewport that will be rendered inside.

Parameters:
Name Type Default Description
c Component | object

The component to add.

render function (el)=>el.createSVGElement()

The function that will be called to render the component. It has to return an HTMLElement of any type.

View Source index.js, line 354

void

# move(deltaX, deltaY) → {Position}

Move the component relative to its current position.

Parameters:
Name Type Description
deltaX number

The amount of

deltaY number

description

View Source index.js, line 337

The new position

Position

# setPosition(pos) → {void}

Set the position of the viewport in the parent. This will move the children as well.

Parameters:
Name Type Description
pos object

The new position of the viewport.

x number

The new x position.

y number

The new y position.

View Source index.js, line 291

void

# setViewboxScale(newScale) → {void}

Change the scale of the element using the viewBox property.

Parameters:
Name Type Description
newScale number

The new scale of the element

View Source index.js, line 326

void