Constructor

WorkspaceDragSurfaceSvg

new WorkspaceDragSurfaceSvg(container)

Blocks are moved into this SVG during a drag, improving performance. The entire SVG is translated using css transforms instead of SVG so the blocks are never repainted during drag improving performance.

Parameter

container

Element

Containing element.

Value must not be null.

Property

SVG_

Dom structure when the workspace is being dragged. If there is no drag in progress, the SVG is empty and display: none.

/g>

Methods

clearAndHide

clearAndHide(newSurface)

Move the blockCanvas and bubbleCanvas out of the surface SVG and on to newSurface.

Parameter

newSurface

SVGElement

The element to put the drag surface contents into.

createDom

createDom()

Create the drag surface and inject it into the container.

getSurfaceTranslation

getSurfaceTranslation() returns goog.math.Coordinate

Reports the surface translation in scaled workspace coordinates. Use this when finishing a drag to return blocks to the correct position.

Returns

non-null goog.math.Coordinate Current translation of the surface

setContentsAndShow

setContentsAndShow(blockCanvas, bubbleCanvas, previousSibling, width, height, scale)

Set the SVG to have the block canvas and bubble canvas in it and then show the surface.

Parameter

blockCanvas

Element

The block canvas element from the workspace.

Value must not be null.

bubbleCanvas

Element

The element that contains the bubbles.

Value must not be null.

previousSibling

Element

The element to insert the block canvas & bubble canvas after when it goes back in the DOM at the end of a drag.

Value may be null.

width

number

The width of the workspace SVG element.

height

number

The height of the workspace SVG element.

scale

number

The scale of the workspace being dragged.

translateSurface

translateSurface(x, y)

Translate the entire drag surface during a drag. We translate the drag surface instead of the blocks inside the surface so that the browser avoids repainting the SVG. Because of this, the drag coordinates must be adjusted by scale.

Parameter

x

number

X translation for the entire surface

y

number

Y translation for the entire surface