This example uses OpenLayers v10.9.0. The latest is v.
Edit

#### Custom Interactions

drag 5 feature 12 vector 86 editing 2 custom 6 interaction 6

#####

Example of a custom interaction.

This example demonstrates creating a custom interaction by subclassing `ol/interaction/Pointer`. Note that the built in interaction `ol/interaction/Translate` might be a better option for moving features.

##### main.js

    import Feature from 'ol/Feature.js';
    import Map from 'ol/Map.js';
    import View from 'ol/View.js';
    import LineString from 'ol/geom/LineString.js';
    import Point from 'ol/geom/Point.js';
    import Polygon from 'ol/geom/Polygon.js';
    import PointerInteraction from 'ol/interaction/Pointer.js';
    import {defaults as defaultInteractions} from 'ol/interaction/defaults.js';
    import TileLayer from 'ol/layer/Tile.js';
    import VectorLayer from 'ol/layer/Vector.js';
    import OGCMapTile from 'ol/source/OGCMapTile.js';
    import VectorSource from 'ol/source/Vector.js';

    class Drag extends PointerInteraction {
      constructor() {
        super({
          handleDownEvent: handleDownEvent,
          handleDragEvent: handleDragEvent,
          handleMoveEvent: handleMoveEvent,
          handleUpEvent: handleUpEvent,
        });

        /**
         * @type {import('ol/coordinate.js').Coordinate}
         * @private
         */
        this.coordinate_ = null;

        /**
         * @type {string|undefined}
         * @private
         */
        this.cursor_ = 'pointer';

        /**
         * @type {Feature}
         * @private
         */
        this.feature_ = null;

        /**
         * @type {string|undefined}
         * @private
         */
        this.previousCursor_ = undefined;
      }
    }

    /**
     * @param {import('ol/MapBrowserEvent.js').default} evt Map browser event.
     * @return {boolean} `true` to start the drag sequence.
     */
    function handleDownEvent(evt) {
      const map = evt.map;

      const feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
        return feature;
      });

      if (feature) {
        this.coordinate_ = evt.coordinate;
        this.feature_ = feature;
      }

      return !!feature;
    }

    /**
     * @param {import('ol/MapBrowserEvent.js').default} evt Map browser event.
     */
    function handleDragEvent(evt) {
      const deltaX = evt.coordinate[0] - this.coordinate_[0];
      const deltaY = evt.coordinate[1] - this.coordinate_[1];

      const geometry = this.feature_.getGeometry();
      geometry.translate(deltaX, deltaY);

      this.coordinate_[0] = evt.coordinate[0];
      this.coordinate_[1] = evt.coordinate[1];
    }

    /**
     * @param {import('ol/MapBrowserEvent.js').default} evt Event.
     */
    function handleMoveEvent(evt) {
      if (this.cursor_) {
        const map = evt.map;
        const feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
          return feature;
        });
        const element = evt.map.getTargetElement();
        if (feature) {
          if (element.style.cursor != this.cursor_) {
            this.previousCursor_ = element.style.cursor;
            element.style.cursor = this.cursor_;
          }
        } else if (this.previousCursor_ !== undefined) {
          element.style.cursor = this.previousCursor_;
          this.previousCursor_ = undefined;
        }
      }
    }

    /**
     * @return {boolean} `false` to stop the drag sequence.
     */
    function handleUpEvent() {
      this.coordinate_ = null;
      this.feature_ = null;
      return false;
    }

    const pointFeature = new Feature(new Point([0, 0]));

    const lineFeature = new Feature(
      new LineString([
        [-1e7, 1e6],
        [-1e6, 3e6],
      ]),
    );

    const polygonFeature = new Feature(
      new Polygon([
        [
          [-3e6, -1e6],
          [-3e6, 1e6],
          [-1e6, 1e6],
          [-1e6, -1e6],
          [-3e6, -1e6],
        ],
      ]),
    );

    const map = new Map({
      interactions: defaultInteractions().extend([new Drag()]),
      layers: [
        new TileLayer({
          source: new OGCMapTile({
            url: 'https://maps.gnosis.earth/ogcapi/collections/NaturalEarth:raster:HYP_HR_SR_OB_DR/map/tiles/WebMercatorQuad',
            crossOrigin: '',
          }),
        }),
        new VectorLayer({
          source: new VectorSource({
            features: [pointFeature, lineFeature, polygonFeature],
          }),
          style: {
            'icon-src': 'data/icon.png',
            'icon-opacity': 0.95,
            'icon-anchor': [0.5, 46],
            'icon-anchor-x-units': 'fraction',
            'icon-anchor-y-units': 'pixels',
            'stroke-width': 3,
            'stroke-color': [255, 0, 0, 1],
            'fill-color': [0, 0, 255, 0.6],
          },
        }),
      ],
      target: 'map',
      view: new View({
        center: [0, 0],
        zoom: 2,
      }),
    });

##### index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>Custom Interactions</title>
        <link rel="stylesheet" href="node_modules/ol/ol.css">
        <style>
          .map {
            width: 100%;
            height: 400px;
          }
        </style>
      </head>
      <body>
        <div id="map" class="map"></div>

        <script type="module" src="main.js"></script>
      </body>
    </html>

##### package.json

    {
      "name": "custom-interactions",
      "dependencies": {
        "ol": "10.9.0"
      },
      "devDependencies": {
        "vite": "^3.2.3"
      },
      "scripts": {
        "start": "vite",
        "build": "vite build"
      }
    }