blockly > BlockDragSurfaceSvg

BlockDragSurfaceSvg class

Class for a drag surface for the currently dragged block. This is a separate SVG that contains only the currently moving block, or nothing.


export declare class BlockDragSurfaceSvg 


Constructor Modifiers Description
(constructor)(container) Constructs a new instance of the BlockDragSurfaceSvg class


Method Modifiers Description
clearAndHide(opt_newSurface) Clear the group and hide the surface; move the blocks off onto the provided element. If the block is being deleted it doesn't need to go back to the original surface, since it would be removed immediately during dispose.
createDom() Create the drag surface and inject it into the container.
getCurrentBlock() Get the current blocks on the drag surface, if any (primarily for BlockSvg.getRelativeToSurfaceXY).
getGroup() Provide a reference to the drag group (primarily for BlockSvg.getRelativeToSurfaceXY).
getSurfaceTranslation() Reports the surface translation in scaled workspace coordinates. Use this when finishing a drag to return blocks to the correct position.
getSvgRoot() Returns the SVG drag surface.
getWsTranslation() Gets the translation of the child block surface This surface is in charge of keeping track of how much the workspace has moved.
setBlocksAndShow(blocks) Set the SVG blocks on the drag surface's group and show the surface. Only one block group should be on the drag surface at a time.
translateAndScaleGroup(x, y, scale) Translate and scale the entire drag surface group to the given position, to keep in sync with the workspace.
translateBy(deltaX, deltaY) Translates the entire surface by a relative offset.
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.