planetary.js/site/public/documentation/builtin_drag.md

778 B

Drag Plugin

The drag plugin allows for modifying the planet's projection's rotation with the mouse. It supports dragging vertically with hard stops at the north and south poles, and dragging horizontally without restriction.

API

planetaryjs.plugins.drag([config])

Valid keys for config are:

  • onDragStart, onDragEnd, onDrag, afterDrag: hooks to the d3.behavior.drag object's dragstart, dragend, and drag events; each defaults to a no-op. onDrag fires at the start of the drag event, afterDrag at the end.
JavaScript
planetaryjs.plugins.drag({
  onDrag: function() {
    console.log("The planet was dragged!", d3.event);
  }
});