@antv/g-plugin-dom-interaction
Advanced tools
Comparing version 1.7.48 to 1.7.49
@@ -334,46 +334,7 @@ import { AbstractRendererPlugin } from '@antv/g-lite'; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
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, _toPropertyKey(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) { | ||
@@ -386,55 +347,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _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) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
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); | ||
}; | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
@@ -447,143 +355,140 @@ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i; | ||
function DOMInteractionPlugin() { | ||
_classCallCheck(this, DOMInteractionPlugin); | ||
this.context = void 0; | ||
} | ||
_createClass(DOMInteractionPlugin, [{ | ||
key: "apply", | ||
value: function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
var _proto = DOMInteractionPlugin.prototype; | ||
_proto.apply = function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
} | ||
}]); | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
}; | ||
return DOMInteractionPlugin; | ||
@@ -594,25 +499,19 @@ }(); | ||
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) { | ||
_inherits(Plugin, _AbstractRendererPlug); | ||
var _super = _createSuper(Plugin); | ||
_inheritsLoose(Plugin, _AbstractRendererPlug); | ||
function Plugin() { | ||
var _this; | ||
_classCallCheck(this, Plugin); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this; | ||
_this.name = 'dom-interaction'; | ||
return _this; | ||
} | ||
_createClass(Plugin, [{ | ||
key: "init", | ||
value: function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
} | ||
}]); | ||
var _proto = Plugin.prototype; | ||
_proto.init = function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
}; | ||
_proto.destroy = function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
}; | ||
return Plugin; | ||
@@ -619,0 +518,0 @@ }(AbstractRendererPlugin); |
@@ -338,46 +338,7 @@ 'use strict'; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
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, _toPropertyKey(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) { | ||
@@ -390,55 +351,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _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) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
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); | ||
}; | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
@@ -451,143 +359,140 @@ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i; | ||
function DOMInteractionPlugin() { | ||
_classCallCheck(this, DOMInteractionPlugin); | ||
this.context = void 0; | ||
} | ||
_createClass(DOMInteractionPlugin, [{ | ||
key: "apply", | ||
value: function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
var _proto = DOMInteractionPlugin.prototype; | ||
_proto.apply = function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
} | ||
}]); | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
}; | ||
return DOMInteractionPlugin; | ||
@@ -598,25 +503,19 @@ }(); | ||
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) { | ||
_inherits(Plugin, _AbstractRendererPlug); | ||
var _super = _createSuper(Plugin); | ||
_inheritsLoose(Plugin, _AbstractRendererPlug); | ||
function Plugin() { | ||
var _this; | ||
_classCallCheck(this, Plugin); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this; | ||
_this.name = 'dom-interaction'; | ||
return _this; | ||
} | ||
_createClass(Plugin, [{ | ||
key: "init", | ||
value: function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
} | ||
}]); | ||
var _proto = Plugin.prototype; | ||
_proto.init = function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
}; | ||
_proto.destroy = function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
}; | ||
return Plugin; | ||
@@ -623,0 +522,0 @@ }(gLite.AbstractRendererPlugin); |
@@ -338,46 +338,7 @@ (function (global, factory) { | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
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, _toPropertyKey(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) { | ||
@@ -390,55 +351,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _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) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
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); | ||
}; | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
@@ -451,143 +359,140 @@ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i; | ||
function DOMInteractionPlugin() { | ||
_classCallCheck(this, DOMInteractionPlugin); | ||
this.context = void 0; | ||
} | ||
_createClass(DOMInteractionPlugin, [{ | ||
key: "apply", | ||
value: function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
var _proto = DOMInteractionPlugin.prototype; | ||
_proto.apply = function apply(context, runtime) { | ||
var _this = this; | ||
var renderingService = context.renderingService, | ||
renderingContext = context.renderingContext, | ||
config = context.config; | ||
this.context = context; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent); | ||
var onPointerMove = function onPointerMove(ev) { | ||
renderingService.hooks.pointerMove.call(ev); | ||
}; | ||
var onPointerUp = function onPointerUp(ev) { | ||
renderingService.hooks.pointerUp.call(ev); | ||
}; | ||
var onPointerDown = function onPointerDown(ev) { | ||
renderingService.hooks.pointerDown.call(ev); | ||
}; | ||
var onPointerOver = function onPointerOver(ev) { | ||
renderingService.hooks.pointerOver.call(ev); | ||
}; | ||
var onPointerOut = function onPointerOut(ev) { | ||
renderingService.hooks.pointerOut.call(ev); | ||
}; | ||
var onPointerCancel = function onPointerCancel(ev) { | ||
renderingService.hooks.pointerCancel.call(ev); | ||
}; | ||
var onPointerWheel = function onPointerWheel(ev) { | ||
renderingService.hooks.pointerWheel.call(ev); | ||
}; | ||
var onClick = function onClick(ev) { | ||
renderingService.hooks.click.call(ev); | ||
}; | ||
var addPointerEventListener = function addPointerEventListener($el) { | ||
runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true); | ||
$el.addEventListener('pointerdown', onPointerDown, true); | ||
$el.addEventListener('pointerleave', onPointerOut, true); | ||
$el.addEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('pointerup', onPointerUp, true); | ||
runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true); | ||
}; | ||
var addTouchEventListener = function addTouchEventListener($el) { | ||
$el.addEventListener('touchstart', onPointerDown, true); | ||
$el.addEventListener('touchend', onPointerUp, true); | ||
$el.addEventListener('touchmove', onPointerMove, true); | ||
$el.addEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var addMouseEventListener = function addMouseEventListener($el) { | ||
runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true); | ||
$el.addEventListener('mousedown', onPointerDown, true); | ||
$el.addEventListener('mouseout', onPointerOut, true); | ||
$el.addEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.addEventListener('mouseup', onPointerUp, true); | ||
}; | ||
var removePointerEventListener = function removePointerEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true); | ||
$el.removeEventListener('pointerdown', onPointerDown, true); | ||
$el.removeEventListener('pointerleave', onPointerOut, true); | ||
$el.removeEventListener('pointerover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('pointerup', onPointerUp, true); | ||
}; | ||
var removeTouchEventListener = function removeTouchEventListener($el) { | ||
$el.removeEventListener('touchstart', onPointerDown, true); | ||
$el.removeEventListener('touchend', onPointerUp, true); | ||
$el.removeEventListener('touchmove', onPointerMove, true); | ||
$el.removeEventListener('touchcancel', onPointerCancel, true); | ||
}; | ||
var removeMouseEventListener = function removeMouseEventListener($el) { | ||
runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true); | ||
$el.removeEventListener('mousedown', onPointerDown, true); | ||
$el.removeEventListener('mouseout', onPointerOut, true); | ||
$el.removeEventListener('mouseover', onPointerOver, true); | ||
runtime.globalThis.removeEventListener('mouseup', onPointerUp, true); | ||
}; | ||
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var $el; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
$el = _this.context.contextService.getDomElement(); // @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = 'none'; | ||
// @ts-ignore | ||
$el.style.msTouchAction = 'none'; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = 'none'; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
addPointerEventListener($el); | ||
} else { | ||
addMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
addTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.addEventListener('click', onClick, true); | ||
} | ||
// use passive event listeners | ||
// @see https://zhuanlan.zhihu.com/p/24555031 | ||
$el.addEventListener('wheel', onPointerWheel, { | ||
passive: true, | ||
capture: true | ||
}); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}))); | ||
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () { | ||
var $el = _this.context.contextService.getDomElement(); | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
if (runtime.globalThis.navigator.msPointerEnabled) { | ||
// @ts-ignore | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
} | ||
}]); | ||
$el.style.msContentZooming = ''; | ||
// @ts-ignore | ||
$el.style.msTouchAction = ''; | ||
} else if (canvas.supportsPointerEvents) { | ||
$el.style.touchAction = ''; | ||
} | ||
if (canvas.supportsPointerEvents) { | ||
removePointerEventListener($el); | ||
} else { | ||
removeMouseEventListener($el); | ||
} | ||
if (canvas.supportsTouchEvents) { | ||
removeTouchEventListener($el); | ||
} | ||
if (config.useNativeClickEvent) { | ||
$el.removeEventListener('click', onClick, true); | ||
} | ||
$el.removeEventListener('wheel', onPointerWheel, true); | ||
}); | ||
}; | ||
return DOMInteractionPlugin; | ||
@@ -598,25 +503,19 @@ }(); | ||
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) { | ||
_inherits(Plugin, _AbstractRendererPlug); | ||
var _super = _createSuper(Plugin); | ||
_inheritsLoose(Plugin, _AbstractRendererPlug); | ||
function Plugin() { | ||
var _this; | ||
_classCallCheck(this, Plugin); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this; | ||
_this.name = 'dom-interaction'; | ||
return _this; | ||
} | ||
_createClass(Plugin, [{ | ||
key: "init", | ||
value: function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
} | ||
}]); | ||
var _proto = Plugin.prototype; | ||
_proto.init = function init() { | ||
this.addRenderingPlugin(new DOMInteractionPlugin()); | ||
}; | ||
_proto.destroy = function destroy() { | ||
this.removeAllRenderingPlugins(); | ||
}; | ||
return Plugin; | ||
@@ -623,0 +522,0 @@ }(gLite.AbstractRendererPlugin); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.DOMInteraction={}),t.window.G)}(this,(function(t,e){"use strict";function n(){n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new j(r||[]);return o(i,"_invoke",{value:L(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var v={};function h(){}function p(){}function d(){}var y={};s(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(k([])));g&&g!==e&&r.call(g,a)&&(y=g);var b=d.prototype=h.prototype=Object.create(y);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function L(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=x(a,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function x(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function k(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return p.prototype=d,o(b,"constructor",{value:d,configurable:!0}),o(d,"constructor",{value:p,configurable:!0}),p.displayName=s(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},E(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new w(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(b),s(b,u,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=k,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;P(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:k(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}function r(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(o=void 0,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(r.key,"string"))?o:o+""),r)}var o}function c(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}function l(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=u(t);if(e){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l(this,n)}}var v=function(){function t(){i(this,t),this.context=void 0}return c(t,[{key:"apply",value:function(e,r){var i=this,a=e.renderingService,c=e.renderingContext,u=e.config;this.context=e;var s=c.root.ownerDocument.defaultView,l=function(t){a.hooks.pointerMove.call(t)},f=function(t){a.hooks.pointerUp.call(t)},v=function(t){a.hooks.pointerDown.call(t)},h=function(t){a.hooks.pointerOver.call(t)},p=function(t){a.hooks.pointerOut.call(t)},d=function(t){a.hooks.pointerCancel.call(t)},y=function(t){a.hooks.pointerWheel.call(t)},m=function(t){a.hooks.click.call(t)},g=function(t){r.globalThis.document.addEventListener("pointermove",l,!0),t.addEventListener("pointerdown",v,!0),t.addEventListener("pointerleave",p,!0),t.addEventListener("pointerover",h,!0),r.globalThis.addEventListener("pointerup",f,!0),r.globalThis.addEventListener("pointercancel",d,!0)},b=function(t){t.addEventListener("touchstart",v,!0),t.addEventListener("touchend",f,!0),t.addEventListener("touchmove",l,!0),t.addEventListener("touchcancel",d,!0)},E=function(t){r.globalThis.document.addEventListener("mousemove",l,!0),t.addEventListener("mousedown",v,!0),t.addEventListener("mouseout",p,!0),t.addEventListener("mouseover",h,!0),r.globalThis.addEventListener("mouseup",f,!0)};a.hooks.init.tapPromise(t.tag,o(n().mark((function t(){var e;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=i.context.contextService.getDomElement(),r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?g(e):E(e),s.supportsTouchEvents&&b(e),u.useNativeClickEvent&&e.addEventListener("click",m,!0),e.addEventListener("wheel",y,{passive:!0,capture:!0});case 6:case"end":return t.stop()}}),t)})))),a.hooks.destroy.tap(t.tag,(function(){var t=i.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){r.globalThis.document.removeEventListener("pointermove",l,!0),t.removeEventListener("pointerdown",v,!0),t.removeEventListener("pointerleave",p,!0),t.removeEventListener("pointerover",h,!0),r.globalThis.removeEventListener("pointerup",f,!0)}(t):function(t){r.globalThis.document.removeEventListener("mousemove",l,!0),t.removeEventListener("mousedown",v,!0),t.removeEventListener("mouseout",p,!0),t.removeEventListener("mouseover",h,!0),r.globalThis.removeEventListener("mouseup",f,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",v,!0),t.removeEventListener("touchend",f,!0),t.removeEventListener("touchmove",l,!0),t.removeEventListener("touchcancel",d,!0)}(t),u.useNativeClickEvent&&t.removeEventListener("click",m,!0),t.removeEventListener("wheel",y,!0)}))}}]),t}();v.tag="DOMInteraction";var h=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(n,t);var e=f(n);function n(){var t;i(this,n);for(var r=arguments.length,o=Array(r),a=0;r>a;a++)o[a]=arguments[a];return(t=e.call.apply(e,[this].concat(o))).name="dom-interaction",t}return c(n,[{key:"init",value:function(){this.addRenderingPlugin(new v)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}]),n}(e.AbstractRendererPlugin);t.Plugin=h,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.DOMInteraction={}),t.window.G)}(this,(function(t,e){"use strict";function n(){n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new P(r||[]);return o(i,"_invoke",{value:b(t,n,a)}),i}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var v={};function f(){}function p(){}function d(){}var m={};s(m,a,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(T([])));g&&g!==e&&r.call(g,a)&&(m=g);var E=d.prototype=f.prototype=Object.create(m);function L(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function b(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return _()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=x(a,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function x(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=h(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return p.prototype=d,o(E,"constructor",{value:d,configurable:!0}),o(d,"constructor",{value:p,configurable:!0}),p.displayName=s(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s(t,u,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},L(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new w(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(E),s(E,u,"Generator"),s(E,a,(function(){return this})),s(E,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=T,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}function r(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var a=function(){function t(){this.context=void 0}return t.prototype.apply=function(e,r){var i=this,a=e.renderingService,c=e.renderingContext,u=e.config;this.context=e;var s=c.root.ownerDocument.defaultView,l=function(t){a.hooks.pointerMove.call(t)},h=function(t){a.hooks.pointerUp.call(t)},v=function(t){a.hooks.pointerDown.call(t)},f=function(t){a.hooks.pointerOver.call(t)},p=function(t){a.hooks.pointerOut.call(t)},d=function(t){a.hooks.pointerCancel.call(t)},m=function(t){a.hooks.pointerWheel.call(t)},y=function(t){a.hooks.click.call(t)},g=function(t){r.globalThis.document.addEventListener("pointermove",l,!0),t.addEventListener("pointerdown",v,!0),t.addEventListener("pointerleave",p,!0),t.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",h,!0),r.globalThis.addEventListener("pointercancel",d,!0)},E=function(t){t.addEventListener("touchstart",v,!0),t.addEventListener("touchend",h,!0),t.addEventListener("touchmove",l,!0),t.addEventListener("touchcancel",d,!0)},L=function(t){r.globalThis.document.addEventListener("mousemove",l,!0),t.addEventListener("mousedown",v,!0),t.addEventListener("mouseout",p,!0),t.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",h,!0)};a.hooks.init.tapPromise(t.tag,o(n().mark((function t(){var e;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=i.context.contextService.getDomElement(),r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?g(e):L(e),s.supportsTouchEvents&&E(e),u.useNativeClickEvent&&e.addEventListener("click",y,!0),e.addEventListener("wheel",m,{passive:!0,capture:!0});case 6:case"end":return t.stop()}}),t)})))),a.hooks.destroy.tap(t.tag,(function(){var t=i.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){r.globalThis.document.removeEventListener("pointermove",l,!0),t.removeEventListener("pointerdown",v,!0),t.removeEventListener("pointerleave",p,!0),t.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",h,!0)}(t):function(t){r.globalThis.document.removeEventListener("mousemove",l,!0),t.removeEventListener("mousedown",v,!0),t.removeEventListener("mouseout",p,!0),t.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",h,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",v,!0),t.removeEventListener("touchend",h,!0),t.removeEventListener("touchmove",l,!0),t.removeEventListener("touchcancel",d,!0)}(t),u.useNativeClickEvent&&t.removeEventListener("click",y,!0),t.removeEventListener("wheel",m,!0)}))},t}();a.tag="DOMInteraction";var c=function(t){var e,n;function r(){for(var e,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];return(e=t.call.apply(t,[this].concat(r))||this).name="dom-interaction",e}(e=r).prototype=Object.create((n=t).prototype),e.prototype.constructor=e,i(e,n);var o=r.prototype;return o.init=function(){this.addRenderingPlugin(new a)},o.destroy=function(){this.removeAllRenderingPlugins()},r}(e.AbstractRendererPlugin);t.Plugin=c,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-dom-interaction", | ||
"version": "1.7.48", | ||
"version": "1.7.49", | ||
"description": "A G plugin", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "059286bbeff21a63e75a41811b89623c37f511f4" | ||
"gitHead": "b9efa0d349c3cb699065f407e45f6aa7e0a3336d" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81693
1609