Back to Grapesjs

Canvas Spot

docs/api/canvas_spot.md

0.22.161.8 KB
Original Source
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

CanvasSpot

Canvas spots are elements drawn on top of the canvas. They can be used to represent anything you might need but the most common use case of canvas spots is rendering information and managing components rendered in the canvas. Read here for more information about Canvas Spots

Properties

  • id String Spot ID.
  • type String Spot type.
  • component Component? Component to which the spot will be attached.
  • componentView ComponentView? ComponentView to which the spot will be attached.
  • boxRect Object? Fixed box rect of the spot, eg. { width: 100, height: 100, x: 0, y: 0 }.

getBoxRect

Get the box rect of the spot.

Parameters

  • opts Object (optional, default {})

Examples

javascript
canvasSpot.getBoxRect();
// { width: 100, height: 50, x: 0, y: 0 }

Returns Object The box rect object

getStyle

Get the style object of the spot.

Parameters

  • opts Object (optional, default {})

Examples

javascript
canvasSpot.getStyle();
// { width: '100px', height: '...', ... }

Returns CSSStyleDeclaration [opts]

isType

Check the spot type.

Parameters

Examples

javascript
canvasSpot.isType('select');

Returns Boolean