Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g

Package Overview
Dependencies
Maintainers
8
Versions
359
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g - npm Package Compare versions

Comparing version 3.4.0-beta.11 to 3.4.0-beta.12

55

lib/core/mixin/event.js

@@ -5,3 +5,3 @@ var Util = require('../../util/index');

var EVENTS = ['mousedown', 'mouseup', 'dblclick', 'contextmenu', 'mouseenter', 'mouseout', 'mouseover', 'mousemove', 'mouseleave'];
var EVENTS = ['mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseout', 'mouseover', 'mousemove', 'mouseleave'];
var CLICK_OFFSET = 40;

@@ -13,2 +13,3 @@ var LEFT_BTN_CODE = 0;

var dragging = null;
var dragTimer = null;
module.exports = {

@@ -39,2 +40,7 @@ registerEvent: function registerEvent() {

}, false);
el.addEventListener('contextmenu', function (e) {
self._triggerEvent('contextmenu', e);
e.preventDefault();
}, false);
},

@@ -66,8 +72,9 @@ _getEmitter: function _getEmitter(element, event) {

_triggerEvent: function _triggerEvent(type, e) {
var point = this.getPointByClient(e.clientX, e.clientY);
var shape = this.getShape(point.x, point.y, e);
var el = this.get('el'); // svg原生事件取不到dragover, dragout, drop等事件的对象。这边需要走数学拾取。
var self = this;
var point = self.getPointByClient(e.clientX, e.clientY);
var shape = self.getShape(point.x, point.y, e);
var el = self.get('el'); // svg原生事件取不到dragover, dragout, drop等事件的对象。这边需要走数学拾取。
if (dragging && this.getRenderer() === 'svg') {
shape = this.getShape(point.x, point.y);
if (dragging && self.getRenderer() === 'svg') {
shape = self.getShape(point.x, point.y);
}

@@ -77,8 +84,8 @@

if (preShape && preShape !== shape) {
this._emitEvent('mouseout', e, point, preShape);
self._emitEvent('mouseout', e, point, preShape);
this._emitEvent('mouseleave', e, point, preShape);
self._emitEvent('mouseleave', e, point, preShape);
if (dragging) {
this._emitEvent('dragleave', e, point, preShape);
self._emitEvent('dragleave', e, point, preShape);
}

@@ -93,3 +100,3 @@

if (dragging) {
this._emitEvent('drag', e, point, dragging);
self._emitEvent('drag', e, point, dragging);
}

@@ -99,6 +106,3 @@

if (!dragging) {
var dx = mousedownOffset.x - e.clientX;
var dy = mousedownOffset.y - e.clientY;
if (mousedownShape === shape && dx * dx + dy * dy >= CLICK_OFFSET) {
if (mousedownShape === shape) {
dragging = shape;

@@ -109,3 +113,3 @@ mousedownShape = null;

} else {
this._emitEvent('mousemove', e, point, shape);
self._emitEvent('mousemove', e, point, shape);
}

@@ -115,14 +119,14 @@ }

if (preShape !== shape) {
this._emitEvent('mouseenter', e, point, shape);
self._emitEvent('mouseenter', e, point, shape);
this._emitEvent('mouseover', e, point, shape);
self._emitEvent('mouseover', e, point, shape);
if (dragging) {
this._emitEvent('dragenter', e, point, shape);
self._emitEvent('dragenter', e, point, shape);
}
}
} else {
var canvasmousemove = this._getEventObj('mousemove', e, point, this);
var canvasmousemove = self._getEventObj('mousemove', e, point, self);
this.emit('mousemove', canvasmousemove);
self.emit('mousemove', canvasmousemove);
}

@@ -144,9 +148,10 @@

if (type === 'mouseup' && e.button === LEFT_BTN_CODE) {
var _dx = mousedownOffset.x - e.clientX;
var dx = mousedownOffset.x - e.clientX;
var dy = mousedownOffset.y - e.clientY;
var dist = dx * dx + dy * dy;
var _dy = mousedownOffset.y - e.clientY;
if (dist < CLICK_OFFSET) {
clearTimeout(dragTimer);
dragTimer = null;
var dist = _dx * _dx + _dy * _dy;
if (dist < CLICK_OFFSET) {
this._emitEvent('click', e, point, mousedownShape || this);

@@ -153,0 +158,0 @@ }

@@ -23,3 +23,3 @@ module.exports = {

// version, etc.
version: '3.4.0-beta.11'
version: '3.4.0-beta.12'
};
{
"name": "@antv/g",
"version": "3.4.0-beta.11",
"version": "3.4.0-beta.12",
"description": "A canvas library which providing 2d draw for G2.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -7,3 +7,2 @@ const Util = require('../../util/index');

'dblclick',
'contextmenu',
'mouseenter',

@@ -23,2 +22,3 @@ 'mouseout',

let dragging = null;
let dragTimer = null;

@@ -53,2 +53,6 @@ module.exports = {

}, false);
el.addEventListener('contextmenu', e => {
self._triggerEvent('contextmenu', e);
e.preventDefault();
}, false);
},

@@ -79,15 +83,16 @@ _getEmitter(element, event) {

_triggerEvent(type, e) {
const point = this.getPointByClient(e.clientX, e.clientY);
let shape = this.getShape(point.x, point.y, e);
const el = this.get('el');
const self = this;
const point = self.getPointByClient(e.clientX, e.clientY);
let shape = self.getShape(point.x, point.y, e);
const el = self.get('el');
// svg原生事件取不到dragover, dragout, drop等事件的对象。这边需要走数学拾取。
if (dragging && this.getRenderer() === 'svg') {
shape = this.getShape(point.x, point.y);
if (dragging && self.getRenderer() === 'svg') {
shape = self.getShape(point.x, point.y);
}
if (type === 'mousemove') {
if (preShape && preShape !== shape) {
this._emitEvent('mouseout', e, point, preShape);
this._emitEvent('mouseleave', e, point, preShape);
self._emitEvent('mouseout', e, point, preShape);
self._emitEvent('mouseleave', e, point, preShape);
if (dragging) {
this._emitEvent('dragleave', e, point, preShape);
self._emitEvent('dragleave', e, point, preShape);
}

@@ -100,10 +105,7 @@ if (!preShape.get('destroyed')) {

if (dragging) {
this._emitEvent('drag', e, point, dragging);
self._emitEvent('drag', e, point, dragging);
}
if (shape) {
if (!dragging) {
const dx = mousedownOffset.x - e.clientX;
const dy = mousedownOffset.y - e.clientY;
if (mousedownShape === shape &&
dx * dx + dy * dy >= CLICK_OFFSET) {
if (mousedownShape === shape) {
dragging = shape;

@@ -113,15 +115,15 @@ mousedownShape = null;

} else {
this._emitEvent('mousemove', e, point, shape);
self._emitEvent('mousemove', e, point, shape);
}
}
if (preShape !== shape) {
this._emitEvent('mouseenter', e, point, shape);
this._emitEvent('mouseover', e, point, shape);
self._emitEvent('mouseenter', e, point, shape);
self._emitEvent('mouseover', e, point, shape);
if (dragging) {
this._emitEvent('dragenter', e, point, shape);
self._emitEvent('dragenter', e, point, shape);
}
}
} else {
const canvasmousemove = this._getEventObj('mousemove', e, point, this);
this.emit('mousemove', canvasmousemove);
const canvasmousemove = self._getEventObj('mousemove', e, point, self);
self.emit('mousemove', canvasmousemove);
}

@@ -141,2 +143,4 @@ preShape = shape;

if (dist < CLICK_OFFSET) {
clearTimeout(dragTimer);
dragTimer = null;
this._emitEvent('click', e, point, mousedownShape || this);

@@ -143,0 +147,0 @@ }

@@ -23,3 +23,3 @@ module.exports = {

// version, etc.
version: '3.4.0-beta.11'
version: '3.4.0-beta.12'
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc