Blockly. WorkspaceDragSurfaceSvg
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. |
Properties
SVG_
Dom structure when the workspace is being dragged. If there is no drag in progress, the SVG is empty and display: none.
SVG_
non-null SVGElement
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 Blockly.utils.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 Blockly.utils.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 |
SVGElement The block canvas Value must not be null. |
bubbleCanvas |
SVGElement The Value must not be null. |
previousSibling |
Element The element to insert the block canvas and bubble canvas after when it goes back in the DOM at the end of a drag. |
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 |