@antv/g-lite 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +34 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -28
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/plugins/EventPlugin.d.ts +0 -1
- package/dist/services/EventService.d.ts +7 -0
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -9494,13 +9494,35 @@ var EventService = /** @class */ (function () {
|
|
|
9494
9494
|
this.mappingState = {};
|
|
9495
9495
|
this.eventPool.clear();
|
|
9496
9496
|
};
|
|
9497
|
-
EventService.prototype.
|
|
9497
|
+
EventService.prototype.getScale = function () {
|
|
9498
9498
|
var bbox = this.context.contextService.getBoundingClientRect();
|
|
9499
|
-
|
|
9499
|
+
var scaleX = 1;
|
|
9500
|
+
var scaleY = 1;
|
|
9501
|
+
var $el = this.context.contextService.getDomElement();
|
|
9502
|
+
if ($el && bbox) {
|
|
9503
|
+
var offsetWidth = $el.offsetWidth, offsetHeight = $el.offsetHeight;
|
|
9504
|
+
scaleX = bbox.width / offsetWidth;
|
|
9505
|
+
scaleY = bbox.height / offsetHeight;
|
|
9506
|
+
}
|
|
9507
|
+
return {
|
|
9508
|
+
scaleX: scaleX,
|
|
9509
|
+
scaleY: scaleY,
|
|
9510
|
+
bbox: bbox,
|
|
9511
|
+
};
|
|
9512
|
+
};
|
|
9513
|
+
/**
|
|
9514
|
+
* Should account for CSS Transform applied on container.
|
|
9515
|
+
* @see https://github.com/antvis/G/issues/1161
|
|
9516
|
+
* @see https://github.com/antvis/G/issues/1677
|
|
9517
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX
|
|
9518
|
+
*/
|
|
9519
|
+
EventService.prototype.client2Viewport = function (client) {
|
|
9520
|
+
var _a = this.getScale(), scaleX = _a.scaleX, scaleY = _a.scaleY, bbox = _a.bbox;
|
|
9521
|
+
return new Point((client.x - ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0)) / scaleX, (client.y - ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0)) / scaleY);
|
|
9500
9522
|
};
|
|
9501
9523
|
EventService.prototype.viewport2Client = function (canvas) {
|
|
9502
|
-
var
|
|
9503
|
-
return new Point(canvas.x + ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0), canvas.y + ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0));
|
|
9524
|
+
var _a = this.getScale(), scaleX = _a.scaleX, scaleY = _a.scaleY, bbox = _a.bbox;
|
|
9525
|
+
return new Point((canvas.x + ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0)) * scaleX, (canvas.y + ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0)) * scaleY);
|
|
9504
9526
|
};
|
|
9505
9527
|
EventService.prototype.viewport2Canvas = function (_a) {
|
|
9506
9528
|
var x = _a.x, y = _a.y;
|
|
@@ -14465,28 +14487,6 @@ var EventPlugin = /** @class */ (function () {
|
|
|
14465
14487
|
_this.setCursor(_this.context.eventService.cursor);
|
|
14466
14488
|
});
|
|
14467
14489
|
};
|
|
14468
|
-
EventPlugin.prototype.getViewportXY = function (nativeEvent) {
|
|
14469
|
-
var x;
|
|
14470
|
-
var y;
|
|
14471
|
-
/**
|
|
14472
|
-
* Should account for CSS Transform applied on container.
|
|
14473
|
-
* @see https://github.com/antvis/G/issues/1161
|
|
14474
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX
|
|
14475
|
-
*/
|
|
14476
|
-
var offsetX = nativeEvent.offsetX, offsetY = nativeEvent.offsetY, clientX = nativeEvent.clientX, clientY = nativeEvent.clientY;
|
|
14477
|
-
if (this.context.config.supportsCSSTransform &&
|
|
14478
|
-
!isNil(offsetX) &&
|
|
14479
|
-
!isNil(offsetY)) {
|
|
14480
|
-
x = offsetX;
|
|
14481
|
-
y = offsetY;
|
|
14482
|
-
}
|
|
14483
|
-
else {
|
|
14484
|
-
var point = this.context.eventService.client2Viewport(new Point(clientX, clientY));
|
|
14485
|
-
x = point.x;
|
|
14486
|
-
y = point.y;
|
|
14487
|
-
}
|
|
14488
|
-
return { x: x, y: y };
|
|
14489
|
-
};
|
|
14490
14490
|
EventPlugin.prototype.bootstrapEvent = function (event, normalizedEvent, view, nativeEvent) {
|
|
14491
14491
|
event.view = view;
|
|
14492
14492
|
event.originalEvent = null;
|
|
@@ -14502,7 +14502,10 @@ var EventPlugin = /** @class */ (function () {
|
|
|
14502
14502
|
event.tiltY = normalizedEvent.tiltY;
|
|
14503
14503
|
event.twist = normalizedEvent.twist;
|
|
14504
14504
|
this.transferMouseData(event, normalizedEvent);
|
|
14505
|
-
var _a = this.
|
|
14505
|
+
var _a = this.context.eventService.client2Viewport({
|
|
14506
|
+
x: normalizedEvent.clientX,
|
|
14507
|
+
y: normalizedEvent.clientY,
|
|
14508
|
+
}), x = _a.x, y = _a.y;
|
|
14506
14509
|
event.viewport.x = x;
|
|
14507
14510
|
event.viewport.y = y;
|
|
14508
14511
|
var _b = this.context.eventService.viewport2Canvas(event.viewport), canvasX = _b.x, canvasY = _b.y;
|
|
@@ -14529,7 +14532,10 @@ var EventPlugin = /** @class */ (function () {
|
|
|
14529
14532
|
event.deltaX = nativeEvent.deltaX;
|
|
14530
14533
|
event.deltaY = nativeEvent.deltaY;
|
|
14531
14534
|
event.deltaZ = nativeEvent.deltaZ;
|
|
14532
|
-
var _a = this.
|
|
14535
|
+
var _a = this.context.eventService.client2Viewport({
|
|
14536
|
+
x: nativeEvent.clientX,
|
|
14537
|
+
y: nativeEvent.clientY,
|
|
14538
|
+
}), x = _a.x, y = _a.y;
|
|
14533
14539
|
event.viewport.x = x;
|
|
14534
14540
|
event.viewport.y = y;
|
|
14535
14541
|
var _b = this.context.eventService.viewport2Canvas(event.viewport), canvasX = _b.x, canvasY = _b.y;
|