Dart Documentationdock_spawnUndockInitiator

UndockInitiator Class

Listens for events on the element and notifies the listener if an undock event has been invoked. An undock event is invoked when the user clicks on the event and drags is beyond the specified thresholdPixels

Constructors

Code new UndockInitiator(Element element, OnUndock listener, [num thresholdPixels = 10]) #

UndockInitiator(this.element, this.listener, [this.thresholdPixels = 10]) {
  mouseDownHandler = onMouseDown;
  mouseUpHandler = onMouseUp;
  mouseMoveHandler = onMouseMove;
}

Methods

Code bool get enabled() #

bool get enabled() {
  return _enabled;
}

Code void set enabled(bool value) #

void set enabled(bool value) {
  _enabled = value;
  if (_enabled) {
    element.on.mouseDown.add(mouseDownHandler);
  } else {
    element.on.mouseDown.remove(mouseDownHandler);
    window.on.mouseUp.remove(mouseUpHandler);
    window.on.mouseMove.remove(mouseMoveHandler);
  }
}

Code void onMouseDown(MouseEvent e) #

void onMouseDown(MouseEvent e) {
  // Make sure we dont do this on floating dialogs
  if (enabled) {
    window.on.mouseUp.add(mouseUpHandler);
    window.on.mouseMove.add(mouseMoveHandler);
    dragStartPosition = new Point2(e.pageX, e.pageY);
  }
}

Code void onMouseMove(MouseEvent e) #

void onMouseMove(MouseEvent e) {
  Point2 position = new Point2(e.pageX, e.pageY);
  num dx = position.x - dragStartPosition.x;
  num dy = position.y - dragStartPosition.y;
  num distance = Math.sqrt(dx * dx + dy * dy);
  if (distance > thresholdPixels) {
    enabled = false;
    _requestUndock(e);
  }
}

Code void onMouseUp(MouseEvent e) #

void onMouseUp(MouseEvent e) {
  window.on.mouseUp.remove(mouseUpHandler);
  window.on.mouseMove.remove(mouseMoveHandler);
}

Fields

Code Point2 dragStartPosition #

Point2 dragStartPosition;

Code Element element #

Element element;

Code OnUndock listener #

OnUndock listener;

Code var mouseDownHandler #

var mouseDownHandler;

Code var mouseMoveHandler #

var mouseMoveHandler;

Code var mouseUpHandler #

var mouseUpHandler;

Code num thresholdPixels #

num thresholdPixels;