Socket
Socket
Sign inDemoInstall

@antv/g-gesture

Package Overview
Dependencies
Maintainers
58
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-gesture - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

346

dist/index.esm.js
import EE from 'eventemitter3';
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
function _typeof(obj) {
"@babel/helpers - typeof";
_setPrototypeOf(subClass, superClass);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {

@@ -27,3 +92,32 @@ if (self === void 0) {

var clock = typeof performance === 'object' && performance.now ? performance : Date;
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === 'object' && performance.now ? performance : Date;
var PRESS_DELAY = 250; // 计算滑动的方向

@@ -59,4 +153,6 @@

var Gesture = /*#__PURE__*/function (_EE) {
_inheritsLoose(Gesture, _EE);
_inherits(Gesture, _EE);
var _super = _createSuper(Gesture);
// 用来记录当前触发的事件

@@ -66,3 +162,5 @@ function Gesture(el) {

_this = _EE.call(this) || this;
_classCallCheck(this, Gesture);
_this = _super.call(this);
_this.el = void 0;

@@ -282,141 +380,151 @@ _this.evCache = [];

var _proto = Gesture.prototype;
_proto._initEvent = function _initEvent() {
var el = this.el;
el.addEventListener('pointerdown', this._start);
el.addEventListener('pointermove', this._move);
el.addEventListener('pointerup', this._end);
el.addEventListener('pointerupoutside', this._end);
};
_proto.getEventType = function getEventType(point) {
var eventType = this.eventType,
startTime = this.startTime,
startPoints = this.startPoints;
if (eventType) {
return eventType;
_createClass(Gesture, [{
key: "_initEvent",
value: function _initEvent() {
var el = this.el;
el.addEventListener('pointerdown', this._start);
el.addEventListener('pointermove', this._move);
el.addEventListener('pointerup', this._end);
el.addEventListener('pointerupoutside', this._end);
}
}, {
key: "getEventType",
value: function getEventType(point) {
var eventType = this.eventType,
startTime = this.startTime,
startPoints = this.startPoints;
var type; // @ts-ignore
if (eventType) {
return eventType;
}
var panEventListeners = this._events.pan; // 如果没有pan事件的监听,默认都是press
var type; // @ts-ignore
if (!panEventListeners) {
type = 'press';
} else {
// 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
var now = clock.now();
var panEventListeners = this._events.pan; // 如果没有pan事件的监听,默认都是press
if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], point) < 10) {
if (!panEventListeners) {
type = 'press';
} else {
type = 'pan';
// 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
var now = clock.now();
if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], point) < 10) {
type = 'press';
} else {
type = 'pan';
}
}
}
this.eventType = type;
return type;
};
_proto.enable = function enable(eventType) {
this.processEvent[eventType] = true;
} // 是否进行中的事件
;
_proto.isProcess = function isProcess(eventType) {
return this.processEvent[eventType];
} // 触发start事件
;
_proto.emitStart = function emitStart(type, ev) {
if (this.isProcess(type)) {
return;
this.eventType = type;
return type;
}
}, {
key: "enable",
value: function enable(eventType) {
this.processEvent[eventType] = true;
} // 是否进行中的事件
this.enable(type);
}, {
key: "isProcess",
value: function isProcess(eventType) {
return this.processEvent[eventType];
} // 触发start事件
this._emit(type + "start", ev);
} // 触发事件
;
}, {
key: "emitStart",
value: function emitStart(type, ev) {
if (this.isProcess(type)) {
return;
}
_proto._emit = function _emit(type, ev) {
var _el$ownerDocument,
_this2 = this;
this.enable(type);
// 主要是节流处理
this.pushEvent(type, ev);
var el = this.el,
throttleTimer = this.throttleTimer,
emitThrottles = this.emitThrottles;
this._emit("".concat(type, "start"), ev);
} // 触发事件
if (throttleTimer) {
return;
}
}, {
key: "_emit",
value: function _emit(type, ev) {
var _el$ownerDocument,
_this2 = this;
var global = (_el$ownerDocument = el.ownerDocument) === null || _el$ownerDocument === void 0 ? void 0 : _el$ownerDocument.defaultView;
this.throttleTimer = global.requestAnimationFrame(function () {
for (var i = 0, len = emitThrottles.length; i < len; i++) {
var _emitThrottles$i = emitThrottles[i],
_type = _emitThrottles$i.type,
_ev = _emitThrottles$i.ev;
// 主要是节流处理
this.pushEvent(type, ev);
var el = this.el,
throttleTimer = this.throttleTimer,
emitThrottles = this.emitThrottles;
_this2.emit(_type, _ev);
} // 清空
if (throttleTimer) {
return;
}
var global = (_el$ownerDocument = el.ownerDocument) === null || _el$ownerDocument === void 0 ? void 0 : _el$ownerDocument.defaultView;
this.throttleTimer = global.requestAnimationFrame(function () {
for (var i = 0, len = emitThrottles.length; i < len; i++) {
var _emitThrottles$i = emitThrottles[i],
_type = _emitThrottles$i.type,
_ev = _emitThrottles$i.ev;
_this2.throttleTimer = 0;
_this2.emitThrottles.length = 0;
});
} // 触发end事件
;
_this2.emit(_type, _ev);
} // 清空
_proto.emitEnd = function emitEnd(ev) {
var _this3 = this;
var processEvent = this.processEvent;
Object.keys(processEvent).forEach(function (type) {
_this3._emit(type + "end", ev);
_this2.throttleTimer = 0;
_this2.emitThrottles.length = 0;
});
} // 触发end事件
delete processEvent[type];
});
};
}, {
key: "emitEnd",
value: function emitEnd(ev) {
var _this3 = this;
_proto.pushEvent = function pushEvent(type, ev) {
var emitThrottles = this.emitThrottles;
var newEvent = {
type: type,
ev: ev
};
var processEvent = this.processEvent;
Object.keys(processEvent).forEach(function (type) {
_this3._emit("".concat(type, "end"), ev);
for (var i = 0, len = emitThrottles.length; i < len; i++) {
if (emitThrottles[i].type === type) {
emitThrottles.splice(i, 1, newEvent);
return;
}
delete processEvent[type];
});
}
}, {
key: "pushEvent",
value: function pushEvent(type, ev) {
var emitThrottles = this.emitThrottles;
var newEvent = {
type: type,
ev: ev
};
emitThrottles.push(newEvent);
};
for (var i = 0, len = emitThrottles.length; i < len; i++) {
if (emitThrottles[i].type === type) {
emitThrottles.splice(i, 1, newEvent);
return;
}
}
_proto.clearPressTimeout = function clearPressTimeout() {
if (this.pressTimeout) {
clearTimeout(this.pressTimeout);
this.pressTimeout = null;
emitThrottles.push(newEvent);
}
};
}, {
key: "clearPressTimeout",
value: function clearPressTimeout() {
if (this.pressTimeout) {
clearTimeout(this.pressTimeout);
this.pressTimeout = null;
}
}
}, {
key: "reset",
value: function reset() {
this.clearPressTimeout();
this.startTime = 0;
this.startDistance = 0;
this.direction = null;
this.eventType = null;
this.prevMoveTime = 0;
this.prevMovePoint = null;
this.lastMoveTime = 0;
this.lastMovePoint = null;
}
}]);
_proto.reset = function reset() {
this.clearPressTimeout();
this.startTime = 0;
this.startDistance = 0;
this.direction = null;
this.eventType = null;
this.prevMoveTime = 0;
this.prevMovePoint = null;
this.lastMoveTime = 0;
this.lastMovePoint = null;
};
return Gesture;

@@ -423,0 +531,0 @@ }(EE);

@@ -9,18 +9,83 @@ 'use strict';

function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
function _typeof(obj) {
"@babel/helpers - typeof";
_setPrototypeOf(subClass, superClass);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {

@@ -34,3 +99,32 @@ if (self === void 0) {

var clock = typeof performance === 'object' && performance.now ? performance : Date;
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === 'object' && performance.now ? performance : Date;
var PRESS_DELAY = 250; // 计算滑动的方向

@@ -66,4 +160,6 @@

var Gesture = /*#__PURE__*/function (_EE) {
_inheritsLoose(Gesture, _EE);
_inherits(Gesture, _EE);
var _super = _createSuper(Gesture);
// 用来记录当前触发的事件

@@ -73,3 +169,5 @@ function Gesture(el) {

_this = _EE.call(this) || this;
_classCallCheck(this, Gesture);
_this = _super.call(this);
_this.el = void 0;

@@ -289,141 +387,151 @@ _this.evCache = [];

var _proto = Gesture.prototype;
_proto._initEvent = function _initEvent() {
var el = this.el;
el.addEventListener('pointerdown', this._start);
el.addEventListener('pointermove', this._move);
el.addEventListener('pointerup', this._end);
el.addEventListener('pointerupoutside', this._end);
};
_proto.getEventType = function getEventType(point) {
var eventType = this.eventType,
startTime = this.startTime,
startPoints = this.startPoints;
if (eventType) {
return eventType;
_createClass(Gesture, [{
key: "_initEvent",
value: function _initEvent() {
var el = this.el;
el.addEventListener('pointerdown', this._start);
el.addEventListener('pointermove', this._move);
el.addEventListener('pointerup', this._end);
el.addEventListener('pointerupoutside', this._end);
}
}, {
key: "getEventType",
value: function getEventType(point) {
var eventType = this.eventType,
startTime = this.startTime,
startPoints = this.startPoints;
var type; // @ts-ignore
if (eventType) {
return eventType;
}
var panEventListeners = this._events.pan; // 如果没有pan事件的监听,默认都是press
var type; // @ts-ignore
if (!panEventListeners) {
type = 'press';
} else {
// 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
var now = clock.now();
var panEventListeners = this._events.pan; // 如果没有pan事件的监听,默认都是press
if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], point) < 10) {
if (!panEventListeners) {
type = 'press';
} else {
type = 'pan';
// 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
var now = clock.now();
if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], point) < 10) {
type = 'press';
} else {
type = 'pan';
}
}
}
this.eventType = type;
return type;
};
_proto.enable = function enable(eventType) {
this.processEvent[eventType] = true;
} // 是否进行中的事件
;
_proto.isProcess = function isProcess(eventType) {
return this.processEvent[eventType];
} // 触发start事件
;
_proto.emitStart = function emitStart(type, ev) {
if (this.isProcess(type)) {
return;
this.eventType = type;
return type;
}
}, {
key: "enable",
value: function enable(eventType) {
this.processEvent[eventType] = true;
} // 是否进行中的事件
this.enable(type);
}, {
key: "isProcess",
value: function isProcess(eventType) {
return this.processEvent[eventType];
} // 触发start事件
this._emit(type + "start", ev);
} // 触发事件
;
}, {
key: "emitStart",
value: function emitStart(type, ev) {
if (this.isProcess(type)) {
return;
}
_proto._emit = function _emit(type, ev) {
var _el$ownerDocument,
_this2 = this;
this.enable(type);
// 主要是节流处理
this.pushEvent(type, ev);
var el = this.el,
throttleTimer = this.throttleTimer,
emitThrottles = this.emitThrottles;
this._emit("".concat(type, "start"), ev);
} // 触发事件
if (throttleTimer) {
return;
}
}, {
key: "_emit",
value: function _emit(type, ev) {
var _el$ownerDocument,
_this2 = this;
var global = (_el$ownerDocument = el.ownerDocument) === null || _el$ownerDocument === void 0 ? void 0 : _el$ownerDocument.defaultView;
this.throttleTimer = global.requestAnimationFrame(function () {
for (var i = 0, len = emitThrottles.length; i < len; i++) {
var _emitThrottles$i = emitThrottles[i],
_type = _emitThrottles$i.type,
_ev = _emitThrottles$i.ev;
// 主要是节流处理
this.pushEvent(type, ev);
var el = this.el,
throttleTimer = this.throttleTimer,
emitThrottles = this.emitThrottles;
_this2.emit(_type, _ev);
} // 清空
if (throttleTimer) {
return;
}
var global = (_el$ownerDocument = el.ownerDocument) === null || _el$ownerDocument === void 0 ? void 0 : _el$ownerDocument.defaultView;
this.throttleTimer = global.requestAnimationFrame(function () {
for (var i = 0, len = emitThrottles.length; i < len; i++) {
var _emitThrottles$i = emitThrottles[i],
_type = _emitThrottles$i.type,
_ev = _emitThrottles$i.ev;
_this2.throttleTimer = 0;
_this2.emitThrottles.length = 0;
});
} // 触发end事件
;
_this2.emit(_type, _ev);
} // 清空
_proto.emitEnd = function emitEnd(ev) {
var _this3 = this;
var processEvent = this.processEvent;
Object.keys(processEvent).forEach(function (type) {
_this3._emit(type + "end", ev);
_this2.throttleTimer = 0;
_this2.emitThrottles.length = 0;
});
} // 触发end事件
delete processEvent[type];
});
};
}, {
key: "emitEnd",
value: function emitEnd(ev) {
var _this3 = this;
_proto.pushEvent = function pushEvent(type, ev) {
var emitThrottles = this.emitThrottles;
var newEvent = {
type: type,
ev: ev
};
var processEvent = this.processEvent;
Object.keys(processEvent).forEach(function (type) {
_this3._emit("".concat(type, "end"), ev);
for (var i = 0, len = emitThrottles.length; i < len; i++) {
if (emitThrottles[i].type === type) {
emitThrottles.splice(i, 1, newEvent);
return;
}
delete processEvent[type];
});
}
}, {
key: "pushEvent",
value: function pushEvent(type, ev) {
var emitThrottles = this.emitThrottles;
var newEvent = {
type: type,
ev: ev
};
emitThrottles.push(newEvent);
};
for (var i = 0, len = emitThrottles.length; i < len; i++) {
if (emitThrottles[i].type === type) {
emitThrottles.splice(i, 1, newEvent);
return;
}
}
_proto.clearPressTimeout = function clearPressTimeout() {
if (this.pressTimeout) {
clearTimeout(this.pressTimeout);
this.pressTimeout = null;
emitThrottles.push(newEvent);
}
};
}, {
key: "clearPressTimeout",
value: function clearPressTimeout() {
if (this.pressTimeout) {
clearTimeout(this.pressTimeout);
this.pressTimeout = null;
}
}
}, {
key: "reset",
value: function reset() {
this.clearPressTimeout();
this.startTime = 0;
this.startDistance = 0;
this.direction = null;
this.eventType = null;
this.prevMoveTime = 0;
this.prevMovePoint = null;
this.lastMoveTime = 0;
this.lastMovePoint = null;
}
}]);
_proto.reset = function reset() {
this.clearPressTimeout();
this.startTime = 0;
this.startDistance = 0;
this.direction = null;
this.eventType = null;
this.prevMoveTime = 0;
this.prevMovePoint = null;
this.lastMoveTime = 0;
this.lastMovePoint = null;
};
return Gesture;

@@ -430,0 +538,0 @@ }(EE__default['default']);

import type { Buffer, Readback, Texture } from '@antv/g-plugin-device-renderer';
import { ResourceType, Format } from '@antv/g-plugin-device-renderer';
import { Format, ResourceType } from '@antv/g-plugin-device-renderer';
import type { IDevice_WebGPU } from './interfaces';

@@ -4,0 +4,0 @@ import { ResourceBase_WebGPU } from './ResourceBase';

@@ -165,3 +165,3 @@ import type { CSSNumericSumValue, UnitMap } from './CSSNumericSumValue';

numericValues(): CSSNumericValue[];
equals(other: CSSNumericValue): any;
equals(other: CSSNumericValue): boolean;
}

@@ -168,0 +168,0 @@ export declare class CSSMathMin extends CSSMathVariadic {

{
"name": "@antv/g-gesture",
"version": "0.0.3",
"version": "0.0.4",
"description": "G Gesture",

@@ -34,4 +34,4 @@ "keywords": [

"devDependencies": {
"@antv/g-mobile-canvas": "^0.2.0",
"@antv/g-mobile-canvas-element": "^0.1.0"
"@antv/g-mobile-canvas": "^0.2.1",
"@antv/g-mobile-canvas-element": "^0.1.1"
},

@@ -41,3 +41,3 @@ "publishConfig": {

},
"gitHead": "bf0d57ef10d56f48d6258906281b9edb34bffb48"
"gitHead": "90eceace1d9a96e36b20926e853b958c03cf3a67"
}

Sorry, the diff of this file is not supported yet

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