getElementBounds static method

JSObject getElementBounds(
  1. String id
)

Implementation

static JSObject getElementBounds(String id) {
  try {
    var pixRatio = getDevicePixelRatio(Plotline.ctx!);
    var screenHeight = (getScreenHeight(Plotline.ctx!) * pixRatio).round();
    var screenWidth = (getScreenWidth(Plotline.ctx!) * pixRatio).round();
    return Plotline.getViewPositionInWeb(
        id, pixRatio, screenWidth, screenHeight);
  } catch (e) {
    debugPrint("Error in getElementBounds: $e");
    return ({
      'x': -1,
      'y': -1,
      'width': -1,
      'height': -1,
      'left': -1,
      'top': -1,
      'right': -1,
      'bottom': -1
    }.jsify() as JSObject);
  }
}