[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.releaseCapture = exports.setPointerCapture = exports.hasPointerCapture = exports.createEvent = exports.getCapturedShape = void 0;
|
---|
| 4 | const Global_1 = require("./Global");
|
---|
| 5 | const Captures = new Map();
|
---|
| 6 | const SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;
|
---|
| 7 | function getCapturedShape(pointerId) {
|
---|
| 8 | return Captures.get(pointerId);
|
---|
| 9 | }
|
---|
| 10 | exports.getCapturedShape = getCapturedShape;
|
---|
| 11 | function createEvent(evt) {
|
---|
| 12 | return {
|
---|
| 13 | evt,
|
---|
| 14 | pointerId: evt.pointerId,
|
---|
| 15 | };
|
---|
| 16 | }
|
---|
| 17 | exports.createEvent = createEvent;
|
---|
| 18 | function hasPointerCapture(pointerId, shape) {
|
---|
| 19 | return Captures.get(pointerId) === shape;
|
---|
| 20 | }
|
---|
| 21 | exports.hasPointerCapture = hasPointerCapture;
|
---|
| 22 | function setPointerCapture(pointerId, shape) {
|
---|
| 23 | releaseCapture(pointerId);
|
---|
| 24 | const stage = shape.getStage();
|
---|
| 25 | if (!stage)
|
---|
| 26 | return;
|
---|
| 27 | Captures.set(pointerId, shape);
|
---|
| 28 | if (SUPPORT_POINTER_EVENTS) {
|
---|
| 29 | shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | exports.setPointerCapture = setPointerCapture;
|
---|
| 33 | function releaseCapture(pointerId, target) {
|
---|
| 34 | const shape = Captures.get(pointerId);
|
---|
| 35 | if (!shape)
|
---|
| 36 | return;
|
---|
| 37 | const stage = shape.getStage();
|
---|
| 38 | if (stage && stage.content) {
|
---|
| 39 | }
|
---|
| 40 | Captures.delete(pointerId);
|
---|
| 41 | if (SUPPORT_POINTER_EVENTS) {
|
---|
| 42 | shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 | exports.releaseCapture = releaseCapture;
|
---|