interaction.js 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041
  1. /*!
  2. * @pixi/interaction - v6.5.10
  3. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  4. *
  5. * @pixi/interaction is licensed under the MIT License.
  6. * http://www.opensource.org/licenses/mit-license
  7. */
  8. this.PIXI = this.PIXI || {};
  9. var _pixi_interaction = (function (exports, math, ticker, display, utils, core) {
  10. 'use strict';
  11. /**
  12. * Holds all information related to an Interaction event
  13. * @memberof PIXI
  14. */
  15. var InteractionData = /** @class */ (function () {
  16. function InteractionData() {
  17. /**
  18. * Pressure applied by the pointing device during the event. A Touch's force property
  19. * will be represented by this value.
  20. * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure
  21. */
  22. this.pressure = 0;
  23. /**
  24. * From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch.
  25. * @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle
  26. */
  27. this.rotationAngle = 0;
  28. /**
  29. * Twist of a stylus pointer.
  30. * @see https://w3c.github.io/pointerevents/#pointerevent-interface
  31. */
  32. this.twist = 0;
  33. /**
  34. * Barrel pressure on a stylus pointer.
  35. * @see https://w3c.github.io/pointerevents/#pointerevent-interface
  36. */
  37. this.tangentialPressure = 0;
  38. this.global = new math.Point();
  39. this.target = null;
  40. this.originalEvent = null;
  41. this.identifier = null;
  42. this.isPrimary = false;
  43. this.button = 0;
  44. this.buttons = 0;
  45. this.width = 0;
  46. this.height = 0;
  47. this.tiltX = 0;
  48. this.tiltY = 0;
  49. this.pointerType = null;
  50. this.pressure = 0;
  51. this.rotationAngle = 0;
  52. this.twist = 0;
  53. this.tangentialPressure = 0;
  54. }
  55. Object.defineProperty(InteractionData.prototype, "pointerId", {
  56. /**
  57. * The unique identifier of the pointer. It will be the same as `identifier`.
  58. * @readonly
  59. * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId
  60. */
  61. get: function () {
  62. return this.identifier;
  63. },
  64. enumerable: false,
  65. configurable: true
  66. });
  67. /**
  68. * This will return the local coordinates of the specified displayObject for this InteractionData
  69. * @param displayObject - The DisplayObject that you would like the local
  70. * coords off
  71. * @param point - A Point object in which to store the value, optional (otherwise
  72. * will create a new point)
  73. * @param globalPos - A Point object containing your custom global coords, optional
  74. * (otherwise will use the current global coords)
  75. * @returns - A point containing the coordinates of the InteractionData position relative
  76. * to the DisplayObject
  77. */
  78. InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) {
  79. return displayObject.worldTransform.applyInverse(globalPos || this.global, point);
  80. };
  81. /**
  82. * Copies properties from normalized event data.
  83. * @param {Touch|MouseEvent|PointerEvent} event - The normalized event data
  84. */
  85. InteractionData.prototype.copyEvent = function (event) {
  86. // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite
  87. // it with "false" on later events when our shim for it on touch events might not be
  88. // accurate
  89. if ('isPrimary' in event && event.isPrimary) {
  90. this.isPrimary = true;
  91. }
  92. this.button = 'button' in event && event.button;
  93. // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard
  94. // event.which property instead, which conveys the same information.
  95. var buttons = 'buttons' in event && event.buttons;
  96. this.buttons = Number.isInteger(buttons) ? buttons : 'which' in event && event.which;
  97. this.width = 'width' in event && event.width;
  98. this.height = 'height' in event && event.height;
  99. this.tiltX = 'tiltX' in event && event.tiltX;
  100. this.tiltY = 'tiltY' in event && event.tiltY;
  101. this.pointerType = 'pointerType' in event && event.pointerType;
  102. this.pressure = 'pressure' in event && event.pressure;
  103. this.rotationAngle = 'rotationAngle' in event && event.rotationAngle;
  104. this.twist = ('twist' in event && event.twist) || 0;
  105. this.tangentialPressure = ('tangentialPressure' in event && event.tangentialPressure) || 0;
  106. };
  107. /** Resets the data for pooling. */
  108. InteractionData.prototype.reset = function () {
  109. // isPrimary is the only property that we really need to reset - everything else is
  110. // guaranteed to be overwritten
  111. this.isPrimary = false;
  112. };
  113. return InteractionData;
  114. }());
  115. /*! *****************************************************************************
  116. Copyright (c) Microsoft Corporation.
  117. Permission to use, copy, modify, and/or distribute this software for any
  118. purpose with or without fee is hereby granted.
  119. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  120. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  121. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  122. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  123. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  124. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  125. PERFORMANCE OF THIS SOFTWARE.
  126. ***************************************************************************** */
  127. /* global Reflect, Promise */
  128. var extendStatics = function(d, b) {
  129. extendStatics = Object.setPrototypeOf ||
  130. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  131. function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
  132. return extendStatics(d, b);
  133. };
  134. function __extends(d, b) {
  135. extendStatics(d, b);
  136. function __() { this.constructor = d; }
  137. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  138. }
  139. var __assign = function() {
  140. __assign = Object.assign || function __assign(t) {
  141. var arguments$1 = arguments;
  142. for (var s, i = 1, n = arguments.length; i < n; i++) {
  143. s = arguments$1[i];
  144. for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) { t[p] = s[p]; } }
  145. }
  146. return t;
  147. };
  148. return __assign.apply(this, arguments);
  149. };
  150. function __rest(s, e) {
  151. var t = {};
  152. for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  153. { t[p] = s[p]; } }
  154. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  155. { for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  156. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  157. { t[p[i]] = s[p[i]]; }
  158. } }
  159. return t;
  160. }
  161. function __decorate(decorators, target, key, desc) {
  162. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  163. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") { r = Reflect.decorate(decorators, target, key, desc); }
  164. else { for (var i = decorators.length - 1; i >= 0; i--) { if (d = decorators[i]) { r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; } } }
  165. return c > 3 && r && Object.defineProperty(target, key, r), r;
  166. }
  167. function __param(paramIndex, decorator) {
  168. return function (target, key) { decorator(target, key, paramIndex); }
  169. }
  170. function __metadata(metadataKey, metadataValue) {
  171. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(metadataKey, metadataValue); }
  172. }
  173. function __awaiter(thisArg, _arguments, P, generator) {
  174. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  175. return new (P || (P = Promise))(function (resolve, reject) {
  176. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  177. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  178. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  179. step((generator = generator.apply(thisArg, _arguments || [])).next());
  180. });
  181. }
  182. function __generator(thisArg, body) {
  183. var _ = { label: 0, sent: function() { if (t[0] & 1) { throw t[1]; } return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  184. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  185. function verb(n) { return function (v) { return step([n, v]); }; }
  186. function step(op) {
  187. if (f) { throw new TypeError("Generator is already executing."); }
  188. while (_) { try {
  189. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
  190. if (y = 0, t) { op = [op[0] & 2, t.value]; }
  191. switch (op[0]) {
  192. case 0: case 1: t = op; break;
  193. case 4: _.label++; return { value: op[1], done: false };
  194. case 5: _.label++; y = op[1]; op = [0]; continue;
  195. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  196. default:
  197. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  198. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  199. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  200. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  201. if (t[2]) { _.ops.pop(); }
  202. _.trys.pop(); continue;
  203. }
  204. op = body.call(thisArg, _);
  205. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } }
  206. if (op[0] & 5) { throw op[1]; } return { value: op[0] ? op[1] : void 0, done: true };
  207. }
  208. }
  209. function __createBinding(o, m, k, k2) {
  210. if (k2 === undefined) { k2 = k; }
  211. o[k2] = m[k];
  212. }
  213. function __exportStar(m, exports) {
  214. for (var p in m) { if (p !== "default" && !exports.hasOwnProperty(p)) { exports[p] = m[p]; } }
  215. }
  216. function __values(o) {
  217. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  218. if (m) { return m.call(o); }
  219. if (o && typeof o.length === "number") { return {
  220. next: function () {
  221. if (o && i >= o.length) { o = void 0; }
  222. return { value: o && o[i++], done: !o };
  223. }
  224. }; }
  225. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  226. }
  227. function __read(o, n) {
  228. var m = typeof Symbol === "function" && o[Symbol.iterator];
  229. if (!m) { return o; }
  230. var i = m.call(o), r, ar = [], e;
  231. try {
  232. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { ar.push(r.value); }
  233. }
  234. catch (error) { e = { error: error }; }
  235. finally {
  236. try {
  237. if (r && !r.done && (m = i["return"])) { m.call(i); }
  238. }
  239. finally { if (e) { throw e.error; } }
  240. }
  241. return ar;
  242. }
  243. function __spread() {
  244. var arguments$1 = arguments;
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. { ar = ar.concat(__read(arguments$1[i])); }
  247. return ar;
  248. }
  249. function __spreadArrays() {
  250. var arguments$1 = arguments;
  251. for (var s = 0, i = 0, il = arguments.length; i < il; i++) { s += arguments$1[i].length; }
  252. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  253. { for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  254. { r[k] = a[j]; } }
  255. return r;
  256. };
  257. function __await(v) {
  258. return this instanceof __await ? (this.v = v, this) : new __await(v);
  259. }
  260. function __asyncGenerator(thisArg, _arguments, generator) {
  261. if (!Symbol.asyncIterator) { throw new TypeError("Symbol.asyncIterator is not defined."); }
  262. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  263. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  264. function verb(n) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } }
  265. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  266. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  267. function fulfill(value) { resume("next", value); }
  268. function reject(value) { resume("throw", value); }
  269. function settle(f, v) { if (f(v), q.shift(), q.length) { resume(q[0][0], q[0][1]); } }
  270. }
  271. function __asyncDelegator(o) {
  272. var i, p;
  273. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  274. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  275. }
  276. function __asyncValues(o) {
  277. if (!Symbol.asyncIterator) { throw new TypeError("Symbol.asyncIterator is not defined."); }
  278. var m = o[Symbol.asyncIterator], i;
  279. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  280. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  281. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  282. }
  283. function __makeTemplateObject(cooked, raw) {
  284. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  285. return cooked;
  286. };
  287. function __importStar(mod) {
  288. if (mod && mod.__esModule) { return mod; }
  289. var result = {};
  290. if (mod != null) { for (var k in mod) { if (Object.hasOwnProperty.call(mod, k)) { result[k] = mod[k]; } } }
  291. result.default = mod;
  292. return result;
  293. }
  294. function __importDefault(mod) {
  295. return (mod && mod.__esModule) ? mod : { default: mod };
  296. }
  297. function __classPrivateFieldGet(receiver, privateMap) {
  298. if (!privateMap.has(receiver)) {
  299. throw new TypeError("attempted to get private field on non-instance");
  300. }
  301. return privateMap.get(receiver);
  302. }
  303. function __classPrivateFieldSet(receiver, privateMap, value) {
  304. if (!privateMap.has(receiver)) {
  305. throw new TypeError("attempted to set private field on non-instance");
  306. }
  307. privateMap.set(receiver, value);
  308. return value;
  309. }
  310. /**
  311. * Event class that mimics native DOM events.
  312. * @memberof PIXI
  313. */
  314. var InteractionEvent = /** @class */ (function () {
  315. function InteractionEvent() {
  316. this.stopped = false;
  317. this.stopsPropagatingAt = null;
  318. this.stopPropagationHint = false;
  319. this.target = null;
  320. this.currentTarget = null;
  321. this.type = null;
  322. this.data = null;
  323. }
  324. /** Prevents event from reaching any objects other than the current object. */
  325. InteractionEvent.prototype.stopPropagation = function () {
  326. this.stopped = true;
  327. this.stopPropagationHint = true;
  328. this.stopsPropagatingAt = this.currentTarget;
  329. };
  330. /** Resets the event. */
  331. InteractionEvent.prototype.reset = function () {
  332. this.stopped = false;
  333. this.stopsPropagatingAt = null;
  334. this.stopPropagationHint = false;
  335. this.currentTarget = null;
  336. this.target = null;
  337. };
  338. return InteractionEvent;
  339. }());
  340. /**
  341. * DisplayObjects with the {@link PIXI.interactiveTarget} mixin use this class to track interactions
  342. * @class
  343. * @private
  344. * @memberof PIXI
  345. */
  346. var InteractionTrackingData = /** @class */ (function () {
  347. /**
  348. * @param {number} pointerId - Unique pointer id of the event
  349. * @private
  350. */
  351. function InteractionTrackingData(pointerId) {
  352. this._pointerId = pointerId;
  353. this._flags = InteractionTrackingData.FLAGS.NONE;
  354. }
  355. /**
  356. *
  357. * @private
  358. * @param {number} flag - The interaction flag to set
  359. * @param {boolean} yn - Should the flag be set or unset
  360. */
  361. InteractionTrackingData.prototype._doSet = function (flag, yn) {
  362. if (yn) {
  363. this._flags = this._flags | flag;
  364. }
  365. else {
  366. this._flags = this._flags & (~flag);
  367. }
  368. };
  369. Object.defineProperty(InteractionTrackingData.prototype, "pointerId", {
  370. /**
  371. * Unique pointer id of the event
  372. * @readonly
  373. * @private
  374. * @member {number}
  375. */
  376. get: function () {
  377. return this._pointerId;
  378. },
  379. enumerable: false,
  380. configurable: true
  381. });
  382. Object.defineProperty(InteractionTrackingData.prototype, "flags", {
  383. /**
  384. * State of the tracking data, expressed as bit flags
  385. * @private
  386. * @member {number}
  387. */
  388. get: function () {
  389. return this._flags;
  390. },
  391. set: function (flags) {
  392. this._flags = flags;
  393. },
  394. enumerable: false,
  395. configurable: true
  396. });
  397. Object.defineProperty(InteractionTrackingData.prototype, "none", {
  398. /**
  399. * Is the tracked event inactive (not over or down)?
  400. * @private
  401. * @member {number}
  402. */
  403. get: function () {
  404. return this._flags === InteractionTrackingData.FLAGS.NONE;
  405. },
  406. enumerable: false,
  407. configurable: true
  408. });
  409. Object.defineProperty(InteractionTrackingData.prototype, "over", {
  410. /**
  411. * Is the tracked event over the DisplayObject?
  412. * @private
  413. * @member {boolean}
  414. */
  415. get: function () {
  416. return (this._flags & InteractionTrackingData.FLAGS.OVER) !== 0;
  417. },
  418. set: function (yn) {
  419. this._doSet(InteractionTrackingData.FLAGS.OVER, yn);
  420. },
  421. enumerable: false,
  422. configurable: true
  423. });
  424. Object.defineProperty(InteractionTrackingData.prototype, "rightDown", {
  425. /**
  426. * Did the right mouse button come down in the DisplayObject?
  427. * @private
  428. * @member {boolean}
  429. */
  430. get: function () {
  431. return (this._flags & InteractionTrackingData.FLAGS.RIGHT_DOWN) !== 0;
  432. },
  433. set: function (yn) {
  434. this._doSet(InteractionTrackingData.FLAGS.RIGHT_DOWN, yn);
  435. },
  436. enumerable: false,
  437. configurable: true
  438. });
  439. Object.defineProperty(InteractionTrackingData.prototype, "leftDown", {
  440. /**
  441. * Did the left mouse button come down in the DisplayObject?
  442. * @private
  443. * @member {boolean}
  444. */
  445. get: function () {
  446. return (this._flags & InteractionTrackingData.FLAGS.LEFT_DOWN) !== 0;
  447. },
  448. set: function (yn) {
  449. this._doSet(InteractionTrackingData.FLAGS.LEFT_DOWN, yn);
  450. },
  451. enumerable: false,
  452. configurable: true
  453. });
  454. InteractionTrackingData.FLAGS = Object.freeze({
  455. NONE: 0,
  456. OVER: 1 << 0,
  457. LEFT_DOWN: 1 << 1,
  458. RIGHT_DOWN: 1 << 2,
  459. });
  460. return InteractionTrackingData;
  461. }());
  462. /**
  463. * Strategy how to search through stage tree for interactive objects
  464. * @memberof PIXI
  465. */
  466. var TreeSearch = /** @class */ (function () {
  467. function TreeSearch() {
  468. this._tempPoint = new math.Point();
  469. }
  470. /**
  471. * Recursive implementation for findHit
  472. * @private
  473. * @param interactionEvent - event containing the point that
  474. * is tested for collision
  475. * @param displayObject - the displayObject
  476. * that will be hit test (recursively crawls its children)
  477. * @param func - the function that will be called on each interactive object. The
  478. * interactionEvent, displayObject and hit will be passed to the function
  479. * @param hitTest - this indicates if the objects inside should be hit test against the point
  480. * @param interactive - Whether the displayObject is interactive
  481. * @returns - Returns true if the displayObject hit the point
  482. */
  483. TreeSearch.prototype.recursiveFindHit = function (interactionEvent, displayObject, func, hitTest, interactive) {
  484. var _a;
  485. if (!displayObject || !displayObject.visible) {
  486. return false;
  487. }
  488. var point = interactionEvent.data.global;
  489. // Took a little while to rework this function correctly! But now it is done and nice and optimized! ^_^
  490. //
  491. // This function will now loop through all objects and then only hit test the objects it HAS
  492. // to, not all of them. MUCH faster..
  493. // An object will be hit test if the following is true:
  494. //
  495. // 1: It is interactive.
  496. // 2: It belongs to a parent that is interactive AND one of the parents children have not already been hit.
  497. //
  498. // As another little optimization once an interactive object has been hit we can carry on
  499. // through the scenegraph, but we know that there will be no more hits! So we can avoid extra hit tests
  500. // A final optimization is that an object is not hit test directly if a child has already been hit.
  501. interactive = displayObject.interactive || interactive;
  502. var hit = false;
  503. var interactiveParent = interactive;
  504. // Flag here can set to false if the event is outside the parents hitArea or mask
  505. var hitTestChildren = true;
  506. // If there is a hitArea, no need to test against anything else if the pointer is not within the hitArea
  507. // There is also no longer a need to hitTest children.
  508. if (displayObject.hitArea) {
  509. if (hitTest) {
  510. displayObject.worldTransform.applyInverse(point, this._tempPoint);
  511. if (!displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) {
  512. hitTest = false;
  513. hitTestChildren = false;
  514. }
  515. else {
  516. hit = true;
  517. }
  518. }
  519. interactiveParent = false;
  520. }
  521. // If there is a mask, no need to hitTest against anything else if the pointer is not within the mask.
  522. // We still want to hitTestChildren, however, to ensure a mouseout can still be generated.
  523. // https://github.com/pixijs/pixi.js/issues/5135
  524. else if (displayObject._mask) {
  525. if (hitTest) {
  526. var maskObject = (displayObject._mask.isMaskData
  527. ? displayObject._mask.maskObject : displayObject._mask);
  528. if (maskObject && !((_a = maskObject.containsPoint) === null || _a === void 0 ? void 0 : _a.call(maskObject, point))) {
  529. hitTest = false;
  530. }
  531. }
  532. }
  533. // ** FREE TIP **! If an object is not interactive or has no buttons in it
  534. // (such as a game scene!) set interactiveChildren to false for that displayObject.
  535. // This will allow PixiJS to completely ignore and bypass checking the displayObjects children.
  536. if (hitTestChildren && displayObject.interactiveChildren && displayObject.children) {
  537. var children = displayObject.children;
  538. for (var i = children.length - 1; i >= 0; i--) {
  539. var child = children[i];
  540. // time to get recursive.. if this function will return if something is hit..
  541. var childHit = this.recursiveFindHit(interactionEvent, child, func, hitTest, interactiveParent);
  542. if (childHit) {
  543. // its a good idea to check if a child has lost its parent.
  544. // this means it has been removed whilst looping so its best
  545. if (!child.parent) {
  546. continue;
  547. }
  548. // we no longer need to hit test any more objects in this container as we we
  549. // now know the parent has been hit
  550. interactiveParent = false;
  551. // If the child is interactive , that means that the object hit was actually
  552. // interactive and not just the child of an interactive object.
  553. // This means we no longer need to hit test anything else. We still need to run
  554. // through all objects, but we don't need to perform any hit tests.
  555. if (childHit) {
  556. if (interactionEvent.target) {
  557. hitTest = false;
  558. }
  559. hit = true;
  560. }
  561. }
  562. }
  563. }
  564. // no point running this if the item is not interactive or does not have an interactive parent.
  565. if (interactive) {
  566. // if we are hit testing (as in we have no hit any objects yet)
  567. // We also don't need to worry about hit testing if once of the displayObjects children
  568. // has already been hit - but only if it was interactive, otherwise we need to keep
  569. // looking for an interactive child, just in case we hit one
  570. if (hitTest && !interactionEvent.target) {
  571. // already tested against hitArea if it is defined
  572. if (!displayObject.hitArea && displayObject.containsPoint) {
  573. if (displayObject.containsPoint(point)) {
  574. hit = true;
  575. }
  576. }
  577. }
  578. if (displayObject.interactive) {
  579. if (hit && !interactionEvent.target) {
  580. interactionEvent.target = displayObject;
  581. }
  582. if (func) {
  583. func(interactionEvent, displayObject, !!hit);
  584. }
  585. }
  586. }
  587. return hit;
  588. };
  589. /**
  590. * This function is provides a neat way of crawling through the scene graph and running a
  591. * specified function on all interactive objects it finds. It will also take care of hit
  592. * testing the interactive objects and passes the hit across in the function.
  593. * @private
  594. * @param interactionEvent - event containing the point that
  595. * is tested for collision
  596. * @param displayObject - the displayObject
  597. * that will be hit test (recursively crawls its children)
  598. * @param func - the function that will be called on each interactive object. The
  599. * interactionEvent, displayObject and hit will be passed to the function
  600. * @param hitTest - this indicates if the objects inside should be hit test against the point
  601. * @returns - Returns true if the displayObject hit the point
  602. */
  603. TreeSearch.prototype.findHit = function (interactionEvent, displayObject, func, hitTest) {
  604. this.recursiveFindHit(interactionEvent, displayObject, func, hitTest, false);
  605. };
  606. return TreeSearch;
  607. }());
  608. /**
  609. * Interface for classes that represent a hit area.
  610. *
  611. * It is implemented by the following classes:
  612. * - {@link PIXI.Circle}
  613. * - {@link PIXI.Ellipse}
  614. * - {@link PIXI.Polygon}
  615. * - {@link PIXI.RoundedRectangle}
  616. * @interface IHitArea
  617. * @memberof PIXI
  618. */
  619. /**
  620. * Checks whether the x and y coordinates given are contained within this area
  621. * @method
  622. * @name contains
  623. * @memberof PIXI.IHitArea#
  624. * @param {number} x - The X coordinate of the point to test
  625. * @param {number} y - The Y coordinate of the point to test
  626. * @returns {boolean} Whether the x/y coordinates are within this area
  627. */
  628. /**
  629. * Default property values of interactive objects
  630. * Used by {@link PIXI.InteractionManager} to automatically give all DisplayObjects these properties
  631. * @private
  632. * @name interactiveTarget
  633. * @type {object}
  634. * @memberof PIXI
  635. * @example
  636. * function MyObject() {}
  637. *
  638. * Object.assign(
  639. * DisplayObject.prototype,
  640. * PIXI.interactiveTarget
  641. * );
  642. */
  643. var interactiveTarget = {
  644. interactive: false,
  645. interactiveChildren: true,
  646. hitArea: null,
  647. /**
  648. * If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive
  649. * Setting this changes the 'cursor' property to `'pointer'`.
  650. * @example
  651. * const sprite = new PIXI.Sprite(texture);
  652. * sprite.interactive = true;
  653. * sprite.buttonMode = true;
  654. * @member {boolean}
  655. * @memberof PIXI.DisplayObject#
  656. */
  657. get buttonMode() {
  658. return this.cursor === 'pointer';
  659. },
  660. set buttonMode(value) {
  661. if (value) {
  662. this.cursor = 'pointer';
  663. }
  664. else if (this.cursor === 'pointer') {
  665. this.cursor = null;
  666. }
  667. },
  668. /**
  669. * This defines what cursor mode is used when the mouse cursor
  670. * is hovered over the displayObject.
  671. * @example
  672. * const sprite = new PIXI.Sprite(texture);
  673. * sprite.interactive = true;
  674. * sprite.cursor = 'wait';
  675. * @see https://developer.mozilla.org/en/docs/Web/CSS/cursor
  676. * @member {string}
  677. * @memberof PIXI.DisplayObject#
  678. */
  679. cursor: null,
  680. /**
  681. * Internal set of all active pointers, by identifier
  682. * @member {Map<number, InteractionTrackingData>}
  683. * @memberof PIXI.DisplayObject#
  684. * @private
  685. */
  686. get trackedPointers() {
  687. if (this._trackedPointers === undefined)
  688. { this._trackedPointers = {}; }
  689. return this._trackedPointers;
  690. },
  691. /**
  692. * Map of all tracked pointers, by identifier. Use trackedPointers to access.
  693. * @private
  694. * @type {Map<number, InteractionTrackingData>}
  695. */
  696. _trackedPointers: undefined,
  697. };
  698. // Mix interactiveTarget into DisplayObject.prototype
  699. display.DisplayObject.mixin(interactiveTarget);
  700. var MOUSE_POINTER_ID = 1;
  701. // helpers for hitTest() - only used inside hitTest()
  702. var hitTestEvent = {
  703. target: null,
  704. data: {
  705. global: null,
  706. },
  707. };
  708. /**
  709. * The interaction manager deals with mouse, touch and pointer events.
  710. *
  711. * Any DisplayObject can be interactive if its `interactive` property is set to true.
  712. *
  713. * This manager also supports multitouch.
  714. *
  715. * An instance of this class is automatically created by default, and can be found at `renderer.plugins.interaction`
  716. * @memberof PIXI
  717. */
  718. var InteractionManager = /** @class */ (function (_super) {
  719. __extends(InteractionManager, _super);
  720. /**
  721. * @param {PIXI.CanvasRenderer|PIXI.Renderer} renderer - A reference to the current renderer
  722. * @param options - The options for the manager.
  723. * @param {boolean} [options.autoPreventDefault=true] - Should the manager automatically prevent default browser actions.
  724. * @param {number} [options.interactionFrequency=10] - Maximum frequency (ms) at pointer over/out states will be checked.
  725. * @param {number} [options.useSystemTicker=true] - Whether to add {@link tickerUpdate} to {@link PIXI.Ticker.system}.
  726. */
  727. function InteractionManager(renderer, options) {
  728. var _this = _super.call(this) || this;
  729. options = options || {};
  730. _this.renderer = renderer;
  731. _this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true;
  732. _this.interactionFrequency = options.interactionFrequency || 10;
  733. _this.mouse = new InteractionData();
  734. _this.mouse.identifier = MOUSE_POINTER_ID;
  735. // setting the mouse to start off far off screen will mean that mouse over does
  736. // not get called before we even move the mouse.
  737. _this.mouse.global.set(-999999);
  738. _this.activeInteractionData = {};
  739. _this.activeInteractionData[MOUSE_POINTER_ID] = _this.mouse;
  740. _this.interactionDataPool = [];
  741. _this.eventData = new InteractionEvent();
  742. _this.interactionDOMElement = null;
  743. _this.moveWhenInside = false;
  744. _this.eventsAdded = false;
  745. _this.tickerAdded = false;
  746. _this.mouseOverRenderer = !('PointerEvent' in globalThis);
  747. _this.supportsTouchEvents = 'ontouchstart' in globalThis;
  748. _this.supportsPointerEvents = !!globalThis.PointerEvent;
  749. // this will make it so that you don't have to call bind all the time
  750. _this.onPointerUp = _this.onPointerUp.bind(_this);
  751. _this.processPointerUp = _this.processPointerUp.bind(_this);
  752. _this.onPointerCancel = _this.onPointerCancel.bind(_this);
  753. _this.processPointerCancel = _this.processPointerCancel.bind(_this);
  754. _this.onPointerDown = _this.onPointerDown.bind(_this);
  755. _this.processPointerDown = _this.processPointerDown.bind(_this);
  756. _this.onPointerMove = _this.onPointerMove.bind(_this);
  757. _this.processPointerMove = _this.processPointerMove.bind(_this);
  758. _this.onPointerOut = _this.onPointerOut.bind(_this);
  759. _this.processPointerOverOut = _this.processPointerOverOut.bind(_this);
  760. _this.onPointerOver = _this.onPointerOver.bind(_this);
  761. _this.cursorStyles = {
  762. default: 'inherit',
  763. pointer: 'pointer',
  764. };
  765. _this.currentCursorMode = null;
  766. _this.cursor = null;
  767. _this.resolution = 1;
  768. _this.delayedEvents = [];
  769. _this.search = new TreeSearch();
  770. _this._tempDisplayObject = new display.TemporaryDisplayObject();
  771. _this._eventListenerOptions = { capture: true, passive: false };
  772. /**
  773. * Fired when a pointer device button (usually a mouse left-button) is pressed on the display
  774. * object.
  775. * @event PIXI.InteractionManager#mousedown
  776. * @param {PIXI.InteractionEvent} event - Interaction event
  777. */
  778. /**
  779. * Fired when a pointer device secondary button (usually a mouse right-button) is pressed
  780. * on the display object.
  781. * @event PIXI.InteractionManager#rightdown
  782. * @param {PIXI.InteractionEvent} event - Interaction event
  783. */
  784. /**
  785. * Fired when a pointer device button (usually a mouse left-button) is released over the display
  786. * object.
  787. * @event PIXI.InteractionManager#mouseup
  788. * @param {PIXI.InteractionEvent} event - Interaction event
  789. */
  790. /**
  791. * Fired when a pointer device secondary button (usually a mouse right-button) is released
  792. * over the display object.
  793. * @event PIXI.InteractionManager#rightup
  794. * @param {PIXI.InteractionEvent} event - Interaction event
  795. */
  796. /**
  797. * Fired when a pointer device button (usually a mouse left-button) is pressed and released on
  798. * the display object.
  799. * @event PIXI.InteractionManager#click
  800. * @param {PIXI.InteractionEvent} event - Interaction event
  801. */
  802. /**
  803. * Fired when a pointer device secondary button (usually a mouse right-button) is pressed
  804. * and released on the display object.
  805. * @event PIXI.InteractionManager#rightclick
  806. * @param {PIXI.InteractionEvent} event - Interaction event
  807. */
  808. /**
  809. * Fired when a pointer device button (usually a mouse left-button) is released outside the
  810. * display object that initially registered a
  811. * [mousedown]{@link PIXI.InteractionManager#event:mousedown}.
  812. * @event PIXI.InteractionManager#mouseupoutside
  813. * @param {PIXI.InteractionEvent} event - Interaction event
  814. */
  815. /**
  816. * Fired when a pointer device secondary button (usually a mouse right-button) is released
  817. * outside the display object that initially registered a
  818. * [rightdown]{@link PIXI.InteractionManager#event:rightdown}.
  819. * @event PIXI.InteractionManager#rightupoutside
  820. * @param {PIXI.InteractionEvent} event - Interaction event
  821. */
  822. /**
  823. * Fired when a pointer device (usually a mouse) is moved while over the display object
  824. * @event PIXI.InteractionManager#mousemove
  825. * @param {PIXI.InteractionEvent} event - Interaction event
  826. */
  827. /**
  828. * Fired when a pointer device (usually a mouse) is moved onto the display object
  829. * @event PIXI.InteractionManager#mouseover
  830. * @param {PIXI.InteractionEvent} event - Interaction event
  831. */
  832. /**
  833. * Fired when a pointer device (usually a mouse) is moved off the display object
  834. * @event PIXI.InteractionManager#mouseout
  835. * @param {PIXI.InteractionEvent} event - Interaction event
  836. */
  837. /**
  838. * Fired when a pointer device button is pressed on the display object.
  839. * @event PIXI.InteractionManager#pointerdown
  840. * @param {PIXI.InteractionEvent} event - Interaction event
  841. */
  842. /**
  843. * Fired when a pointer device button is released over the display object.
  844. * Not always fired when some buttons are held down while others are released. In those cases,
  845. * use [mousedown]{@link PIXI.InteractionManager#event:mousedown} and
  846. * [mouseup]{@link PIXI.InteractionManager#event:mouseup} instead.
  847. * @event PIXI.InteractionManager#pointerup
  848. * @param {PIXI.InteractionEvent} event - Interaction event
  849. */
  850. /**
  851. * Fired when the operating system cancels a pointer event
  852. * @event PIXI.InteractionManager#pointercancel
  853. * @param {PIXI.InteractionEvent} event - Interaction event
  854. */
  855. /**
  856. * Fired when a pointer device button is pressed and released on the display object.
  857. * @event PIXI.InteractionManager#pointertap
  858. * @param {PIXI.InteractionEvent} event - Interaction event
  859. */
  860. /**
  861. * Fired when a pointer device button is released outside the display object that initially
  862. * registered a [pointerdown]{@link PIXI.InteractionManager#event:pointerdown}.
  863. * @event PIXI.InteractionManager#pointerupoutside
  864. * @param {PIXI.InteractionEvent} event - Interaction event
  865. */
  866. /**
  867. * Fired when a pointer device is moved while over the display object
  868. * @event PIXI.InteractionManager#pointermove
  869. * @param {PIXI.InteractionEvent} event - Interaction event
  870. */
  871. /**
  872. * Fired when a pointer device is moved onto the display object
  873. * @event PIXI.InteractionManager#pointerover
  874. * @param {PIXI.InteractionEvent} event - Interaction event
  875. */
  876. /**
  877. * Fired when a pointer device is moved off the display object
  878. * @event PIXI.InteractionManager#pointerout
  879. * @param {PIXI.InteractionEvent} event - Interaction event
  880. */
  881. /**
  882. * Fired when a touch point is placed on the display object.
  883. * @event PIXI.InteractionManager#touchstart
  884. * @param {PIXI.InteractionEvent} event - Interaction event
  885. */
  886. /**
  887. * Fired when a touch point is removed from the display object.
  888. * @event PIXI.InteractionManager#touchend
  889. * @param {PIXI.InteractionEvent} event - Interaction event
  890. */
  891. /**
  892. * Fired when the operating system cancels a touch
  893. * @event PIXI.InteractionManager#touchcancel
  894. * @param {PIXI.InteractionEvent} event - Interaction event
  895. */
  896. /**
  897. * Fired when a touch point is placed and removed from the display object.
  898. * @event PIXI.InteractionManager#tap
  899. * @param {PIXI.InteractionEvent} event - Interaction event
  900. */
  901. /**
  902. * Fired when a touch point is removed outside of the display object that initially
  903. * registered a [touchstart]{@link PIXI.InteractionManager#event:touchstart}.
  904. * @event PIXI.InteractionManager#touchendoutside
  905. * @param {PIXI.InteractionEvent} event - Interaction event
  906. */
  907. /**
  908. * Fired when a touch point is moved along the display object.
  909. * @event PIXI.InteractionManager#touchmove
  910. * @param {PIXI.InteractionEvent} event - Interaction event
  911. */
  912. /**
  913. * Fired when a pointer device button (usually a mouse left-button) is pressed on the display.
  914. * object. DisplayObject's `interactive` property must be set to `true` to fire event.
  915. *
  916. * This comes from the @pixi/interaction package.
  917. * @event PIXI.DisplayObject#mousedown
  918. * @param {PIXI.InteractionEvent} event - Interaction event
  919. */
  920. /**
  921. * Fired when a pointer device secondary button (usually a mouse right-button) is pressed
  922. * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
  923. *
  924. * This comes from the @pixi/interaction package.
  925. * @event PIXI.DisplayObject#rightdown
  926. * @param {PIXI.InteractionEvent} event - Interaction event
  927. */
  928. /**
  929. * Fired when a pointer device button (usually a mouse left-button) is released over the display
  930. * object. DisplayObject's `interactive` property must be set to `true` to fire event.
  931. *
  932. * This comes from the @pixi/interaction package.
  933. * @event PIXI.DisplayObject#mouseup
  934. * @param {PIXI.InteractionEvent} event - Interaction event
  935. */
  936. /**
  937. * Fired when a pointer device secondary button (usually a mouse right-button) is released
  938. * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
  939. *
  940. * This comes from the @pixi/interaction package.
  941. * @event PIXI.DisplayObject#rightup
  942. * @param {PIXI.InteractionEvent} event - Interaction event
  943. */
  944. /**
  945. * Fired when a pointer device button (usually a mouse left-button) is pressed and released on
  946. * the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
  947. *
  948. * This comes from the @pixi/interaction package.
  949. * @event PIXI.DisplayObject#click
  950. * @param {PIXI.InteractionEvent} event - Interaction event
  951. */
  952. /**
  953. * Fired when a pointer device secondary button (usually a mouse right-button) is pressed
  954. * and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
  955. *
  956. * This comes from the @pixi/interaction package.
  957. * @event PIXI.DisplayObject#rightclick
  958. * @param {PIXI.InteractionEvent} event - Interaction event
  959. */
  960. /**
  961. * Fired when a pointer device button (usually a mouse left-button) is released outside the
  962. * display object that initially registered a
  963. * [mousedown]{@link PIXI.DisplayObject#event:mousedown}.
  964. * DisplayObject's `interactive` property must be set to `true` to fire event.
  965. *
  966. * This comes from the @pixi/interaction package.
  967. * @event PIXI.DisplayObject#mouseupoutside
  968. * @param {PIXI.InteractionEvent} event - Interaction event
  969. */
  970. /**
  971. * Fired when a pointer device secondary button (usually a mouse right-button) is released
  972. * outside the display object that initially registered a
  973. * [rightdown]{@link PIXI.DisplayObject#event:rightdown}.
  974. * DisplayObject's `interactive` property must be set to `true` to fire event.
  975. *
  976. * This comes from the @pixi/interaction package.
  977. * @event PIXI.DisplayObject#rightupoutside
  978. * @param {PIXI.InteractionEvent} event - Interaction event
  979. */
  980. /**
  981. * Fired when a pointer device (usually a mouse) is moved while over the display object.
  982. * DisplayObject's `interactive` property must be set to `true` to fire event.
  983. *
  984. * This comes from the @pixi/interaction package.
  985. * @event PIXI.DisplayObject#mousemove
  986. * @param {PIXI.InteractionEvent} event - Interaction event
  987. */
  988. /**
  989. * Fired when a pointer device (usually a mouse) is moved onto the display object.
  990. * DisplayObject's `interactive` property must be set to `true` to fire event.
  991. *
  992. * This comes from the @pixi/interaction package.
  993. * @event PIXI.DisplayObject#mouseover
  994. * @param {PIXI.InteractionEvent} event - Interaction event
  995. */
  996. /**
  997. * Fired when a pointer device (usually a mouse) is moved off the display object.
  998. * DisplayObject's `interactive` property must be set to `true` to fire event.
  999. *
  1000. * This comes from the @pixi/interaction package.
  1001. * @event PIXI.DisplayObject#mouseout
  1002. * @param {PIXI.InteractionEvent} event - Interaction event
  1003. */
  1004. /**
  1005. * Fired when a pointer device button is pressed on the display object.
  1006. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1007. *
  1008. * This comes from the @pixi/interaction package.
  1009. * @event PIXI.DisplayObject#pointerdown
  1010. * @param {PIXI.InteractionEvent} event - Interaction event
  1011. */
  1012. /**
  1013. * Fired when a pointer device button is released over the display object.
  1014. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1015. *
  1016. * This comes from the @pixi/interaction package.
  1017. * @event PIXI.DisplayObject#pointerup
  1018. * @param {PIXI.InteractionEvent} event - Interaction event
  1019. */
  1020. /**
  1021. * Fired when the operating system cancels a pointer event.
  1022. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1023. *
  1024. * This comes from the @pixi/interaction package.
  1025. * @event PIXI.DisplayObject#pointercancel
  1026. * @param {PIXI.InteractionEvent} event - Interaction event
  1027. */
  1028. /**
  1029. * Fired when a pointer device button is pressed and released on the display object.
  1030. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1031. *
  1032. * This comes from the @pixi/interaction package.
  1033. * @event PIXI.DisplayObject#pointertap
  1034. * @param {PIXI.InteractionEvent} event - Interaction event
  1035. */
  1036. /**
  1037. * Fired when a pointer device button is released outside the display object that initially
  1038. * registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}.
  1039. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1040. *
  1041. * This comes from the @pixi/interaction package.
  1042. * @event PIXI.DisplayObject#pointerupoutside
  1043. * @param {PIXI.InteractionEvent} event - Interaction event
  1044. */
  1045. /**
  1046. * Fired when a pointer device is moved while over the display object.
  1047. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1048. *
  1049. * This comes from the @pixi/interaction package.
  1050. * @event PIXI.DisplayObject#pointermove
  1051. * @param {PIXI.InteractionEvent} event - Interaction event
  1052. */
  1053. /**
  1054. * Fired when a pointer device is moved onto the display object.
  1055. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1056. *
  1057. * This comes from the @pixi/interaction package.
  1058. * @event PIXI.DisplayObject#pointerover
  1059. * @param {PIXI.InteractionEvent} event - Interaction event
  1060. */
  1061. /**
  1062. * Fired when a pointer device is moved off the display object.
  1063. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1064. *
  1065. * This comes from the @pixi/interaction package.
  1066. * @event PIXI.DisplayObject#pointerout
  1067. * @param {PIXI.InteractionEvent} event - Interaction event
  1068. */
  1069. /**
  1070. * Fired when a touch point is placed on the display object.
  1071. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1072. *
  1073. * This comes from the @pixi/interaction package.
  1074. * @event PIXI.DisplayObject#touchstart
  1075. * @param {PIXI.InteractionEvent} event - Interaction event
  1076. */
  1077. /**
  1078. * Fired when a touch point is removed from the display object.
  1079. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1080. *
  1081. * This comes from the @pixi/interaction package.
  1082. * @event PIXI.DisplayObject#touchend
  1083. * @param {PIXI.InteractionEvent} event - Interaction event
  1084. */
  1085. /**
  1086. * Fired when the operating system cancels a touch.
  1087. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1088. *
  1089. * This comes from the @pixi/interaction package.
  1090. * @event PIXI.DisplayObject#touchcancel
  1091. * @param {PIXI.InteractionEvent} event - Interaction event
  1092. */
  1093. /**
  1094. * Fired when a touch point is placed and removed from the display object.
  1095. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1096. *
  1097. * This comes from the @pixi/interaction package.
  1098. * @event PIXI.DisplayObject#tap
  1099. * @param {PIXI.InteractionEvent} event - Interaction event
  1100. */
  1101. /**
  1102. * Fired when a touch point is removed outside of the display object that initially
  1103. * registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}.
  1104. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1105. *
  1106. * This comes from the @pixi/interaction package.
  1107. * @event PIXI.DisplayObject#touchendoutside
  1108. * @param {PIXI.InteractionEvent} event - Interaction event
  1109. */
  1110. /**
  1111. * Fired when a touch point is moved along the display object.
  1112. * DisplayObject's `interactive` property must be set to `true` to fire event.
  1113. *
  1114. * This comes from the @pixi/interaction package.
  1115. * @event PIXI.DisplayObject#touchmove
  1116. * @param {PIXI.InteractionEvent} event - Interaction event
  1117. */
  1118. _this._useSystemTicker = options.useSystemTicker !== undefined ? options.useSystemTicker : true;
  1119. _this.setTargetElement(_this.renderer.view, _this.renderer.resolution);
  1120. return _this;
  1121. }
  1122. Object.defineProperty(InteractionManager.prototype, "useSystemTicker", {
  1123. /**
  1124. * Should the InteractionManager automatically add {@link tickerUpdate} to {@link PIXI.Ticker.system}.
  1125. * @default true
  1126. */
  1127. get: function () {
  1128. return this._useSystemTicker;
  1129. },
  1130. set: function (useSystemTicker) {
  1131. this._useSystemTicker = useSystemTicker;
  1132. if (useSystemTicker) {
  1133. this.addTickerListener();
  1134. }
  1135. else {
  1136. this.removeTickerListener();
  1137. }
  1138. },
  1139. enumerable: false,
  1140. configurable: true
  1141. });
  1142. Object.defineProperty(InteractionManager.prototype, "lastObjectRendered", {
  1143. /**
  1144. * Last rendered object or temp object.
  1145. * @readonly
  1146. * @protected
  1147. */
  1148. get: function () {
  1149. return this.renderer._lastObjectRendered || this._tempDisplayObject;
  1150. },
  1151. enumerable: false,
  1152. configurable: true
  1153. });
  1154. /**
  1155. * Hit tests a point against the display tree, returning the first interactive object that is hit.
  1156. * @param globalPoint - A point to hit test with, in global space.
  1157. * @param root - The root display object to start from. If omitted, defaults
  1158. * to the last rendered root of the associated renderer.
  1159. * @returns - The hit display object, if any.
  1160. */
  1161. InteractionManager.prototype.hitTest = function (globalPoint, root) {
  1162. // clear the target for our hit test
  1163. hitTestEvent.target = null;
  1164. // assign the global point
  1165. hitTestEvent.data.global = globalPoint;
  1166. // ensure safety of the root
  1167. if (!root) {
  1168. root = this.lastObjectRendered;
  1169. }
  1170. // run the hit test
  1171. this.processInteractive(hitTestEvent, root, null, true);
  1172. // return our found object - it'll be null if we didn't hit anything
  1173. return hitTestEvent.target;
  1174. };
  1175. /**
  1176. * Sets the DOM element which will receive mouse/touch events. This is useful for when you have
  1177. * other DOM elements on top of the renderers Canvas element. With this you'll be bale to delegate
  1178. * another DOM element to receive those events.
  1179. * @param element - the DOM element which will receive mouse and touch events.
  1180. * @param resolution - The resolution / device pixel ratio of the new element (relative to the canvas).
  1181. */
  1182. InteractionManager.prototype.setTargetElement = function (element, resolution) {
  1183. if (resolution === void 0) { resolution = 1; }
  1184. this.removeTickerListener();
  1185. this.removeEvents();
  1186. this.interactionDOMElement = element;
  1187. this.resolution = resolution;
  1188. this.addEvents();
  1189. this.addTickerListener();
  1190. };
  1191. /** Adds the ticker listener. */
  1192. InteractionManager.prototype.addTickerListener = function () {
  1193. if (this.tickerAdded || !this.interactionDOMElement || !this._useSystemTicker) {
  1194. return;
  1195. }
  1196. ticker.Ticker.system.add(this.tickerUpdate, this, ticker.UPDATE_PRIORITY.INTERACTION);
  1197. this.tickerAdded = true;
  1198. };
  1199. /** Removes the ticker listener. */
  1200. InteractionManager.prototype.removeTickerListener = function () {
  1201. if (!this.tickerAdded) {
  1202. return;
  1203. }
  1204. ticker.Ticker.system.remove(this.tickerUpdate, this);
  1205. this.tickerAdded = false;
  1206. };
  1207. /** Registers all the DOM events. */
  1208. InteractionManager.prototype.addEvents = function () {
  1209. if (this.eventsAdded || !this.interactionDOMElement) {
  1210. return;
  1211. }
  1212. var style = this.interactionDOMElement.style;
  1213. if (globalThis.navigator.msPointerEnabled) {
  1214. style.msContentZooming = 'none';
  1215. style.msTouchAction = 'none';
  1216. }
  1217. else if (this.supportsPointerEvents) {
  1218. style.touchAction = 'none';
  1219. }
  1220. /*
  1221. * These events are added first, so that if pointer events are normalized, they are fired
  1222. * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd
  1223. */
  1224. if (this.supportsPointerEvents) {
  1225. globalThis.document.addEventListener('pointermove', this.onPointerMove, this._eventListenerOptions);
  1226. this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, this._eventListenerOptions);
  1227. // pointerout is fired in addition to pointerup (for touch events) and pointercancel
  1228. // we already handle those, so for the purposes of what we do in onPointerOut, we only
  1229. // care about the pointerleave event
  1230. this.interactionDOMElement.addEventListener('pointerleave', this.onPointerOut, this._eventListenerOptions);
  1231. this.interactionDOMElement.addEventListener('pointerover', this.onPointerOver, this._eventListenerOptions);
  1232. globalThis.addEventListener('pointercancel', this.onPointerCancel, this._eventListenerOptions);
  1233. globalThis.addEventListener('pointerup', this.onPointerUp, this._eventListenerOptions);
  1234. }
  1235. else {
  1236. globalThis.document.addEventListener('mousemove', this.onPointerMove, this._eventListenerOptions);
  1237. this.interactionDOMElement.addEventListener('mousedown', this.onPointerDown, this._eventListenerOptions);
  1238. this.interactionDOMElement.addEventListener('mouseout', this.onPointerOut, this._eventListenerOptions);
  1239. this.interactionDOMElement.addEventListener('mouseover', this.onPointerOver, this._eventListenerOptions);
  1240. globalThis.addEventListener('mouseup', this.onPointerUp, this._eventListenerOptions);
  1241. }
  1242. // always look directly for touch events so that we can provide original data
  1243. // In a future version we should change this to being just a fallback and rely solely on
  1244. // PointerEvents whenever available
  1245. if (this.supportsTouchEvents) {
  1246. this.interactionDOMElement.addEventListener('touchstart', this.onPointerDown, this._eventListenerOptions);
  1247. this.interactionDOMElement.addEventListener('touchcancel', this.onPointerCancel, this._eventListenerOptions);
  1248. this.interactionDOMElement.addEventListener('touchend', this.onPointerUp, this._eventListenerOptions);
  1249. this.interactionDOMElement.addEventListener('touchmove', this.onPointerMove, this._eventListenerOptions);
  1250. }
  1251. this.eventsAdded = true;
  1252. };
  1253. /** Removes all the DOM events that were previously registered. */
  1254. InteractionManager.prototype.removeEvents = function () {
  1255. if (!this.eventsAdded || !this.interactionDOMElement) {
  1256. return;
  1257. }
  1258. var style = this.interactionDOMElement.style;
  1259. if (globalThis.navigator.msPointerEnabled) {
  1260. style.msContentZooming = '';
  1261. style.msTouchAction = '';
  1262. }
  1263. else if (this.supportsPointerEvents) {
  1264. style.touchAction = '';
  1265. }
  1266. if (this.supportsPointerEvents) {
  1267. globalThis.document.removeEventListener('pointermove', this.onPointerMove, this._eventListenerOptions);
  1268. this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, this._eventListenerOptions);
  1269. this.interactionDOMElement.removeEventListener('pointerleave', this.onPointerOut, this._eventListenerOptions);
  1270. this.interactionDOMElement.removeEventListener('pointerover', this.onPointerOver, this._eventListenerOptions);
  1271. globalThis.removeEventListener('pointercancel', this.onPointerCancel, this._eventListenerOptions);
  1272. globalThis.removeEventListener('pointerup', this.onPointerUp, this._eventListenerOptions);
  1273. }
  1274. else {
  1275. globalThis.document.removeEventListener('mousemove', this.onPointerMove, this._eventListenerOptions);
  1276. this.interactionDOMElement.removeEventListener('mousedown', this.onPointerDown, this._eventListenerOptions);
  1277. this.interactionDOMElement.removeEventListener('mouseout', this.onPointerOut, this._eventListenerOptions);
  1278. this.interactionDOMElement.removeEventListener('mouseover', this.onPointerOver, this._eventListenerOptions);
  1279. globalThis.removeEventListener('mouseup', this.onPointerUp, this._eventListenerOptions);
  1280. }
  1281. if (this.supportsTouchEvents) {
  1282. this.interactionDOMElement.removeEventListener('touchstart', this.onPointerDown, this._eventListenerOptions);
  1283. this.interactionDOMElement.removeEventListener('touchcancel', this.onPointerCancel, this._eventListenerOptions);
  1284. this.interactionDOMElement.removeEventListener('touchend', this.onPointerUp, this._eventListenerOptions);
  1285. this.interactionDOMElement.removeEventListener('touchmove', this.onPointerMove, this._eventListenerOptions);
  1286. }
  1287. this.interactionDOMElement = null;
  1288. this.eventsAdded = false;
  1289. };
  1290. /**
  1291. * Updates the state of interactive objects if at least {@link interactionFrequency}
  1292. * milliseconds have passed since the last invocation.
  1293. *
  1294. * Invoked by a throttled ticker update from {@link PIXI.Ticker.system}.
  1295. * @param deltaTime - time delta since the last call
  1296. */
  1297. InteractionManager.prototype.tickerUpdate = function (deltaTime) {
  1298. this._deltaTime += deltaTime;
  1299. if (this._deltaTime < this.interactionFrequency) {
  1300. return;
  1301. }
  1302. this._deltaTime = 0;
  1303. this.update();
  1304. };
  1305. /** Updates the state of interactive objects. */
  1306. InteractionManager.prototype.update = function () {
  1307. if (!this.interactionDOMElement) {
  1308. return;
  1309. }
  1310. // if the user move the mouse this check has already been done using the mouse move!
  1311. if (this._didMove) {
  1312. this._didMove = false;
  1313. return;
  1314. }
  1315. this.cursor = null;
  1316. // Resets the flag as set by a stopPropagation call. This flag is usually reset by a user interaction of any kind,
  1317. // but there was a scenario of a display object moving under a static mouse cursor.
  1318. // In this case, mouseover and mouseevents would not pass the flag test in dispatchEvent function
  1319. for (var k in this.activeInteractionData) {
  1320. // eslint-disable-next-line no-prototype-builtins
  1321. if (this.activeInteractionData.hasOwnProperty(k)) {
  1322. var interactionData = this.activeInteractionData[k];
  1323. if (interactionData.originalEvent && interactionData.pointerType !== 'touch') {
  1324. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, interactionData.originalEvent, interactionData);
  1325. this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerOverOut, true);
  1326. }
  1327. }
  1328. }
  1329. this.setCursorMode(this.cursor);
  1330. };
  1331. /**
  1332. * Sets the current cursor mode, handling any callbacks or CSS style changes.
  1333. * @param mode - cursor mode, a key from the cursorStyles dictionary
  1334. */
  1335. InteractionManager.prototype.setCursorMode = function (mode) {
  1336. mode = mode || 'default';
  1337. var applyStyles = true;
  1338. // offscreen canvas does not support setting styles, but cursor modes can be functions,
  1339. // in order to handle pixi rendered cursors, so we can't bail
  1340. if (globalThis.OffscreenCanvas && this.interactionDOMElement instanceof OffscreenCanvas) {
  1341. applyStyles = false;
  1342. }
  1343. // if the mode didn't actually change, bail early
  1344. if (this.currentCursorMode === mode) {
  1345. return;
  1346. }
  1347. this.currentCursorMode = mode;
  1348. var style = this.cursorStyles[mode];
  1349. // only do things if there is a cursor style for it
  1350. if (style) {
  1351. switch (typeof style) {
  1352. case 'string':
  1353. // string styles are handled as cursor CSS
  1354. if (applyStyles) {
  1355. this.interactionDOMElement.style.cursor = style;
  1356. }
  1357. break;
  1358. case 'function':
  1359. // functions are just called, and passed the cursor mode
  1360. style(mode);
  1361. break;
  1362. case 'object':
  1363. // if it is an object, assume that it is a dictionary of CSS styles,
  1364. // apply it to the interactionDOMElement
  1365. if (applyStyles) {
  1366. Object.assign(this.interactionDOMElement.style, style);
  1367. }
  1368. break;
  1369. }
  1370. }
  1371. else if (applyStyles && typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {
  1372. // if it mode is a string (not a Symbol) and cursorStyles doesn't have any entry
  1373. // for the mode, then assume that the dev wants it to be CSS for the cursor.
  1374. this.interactionDOMElement.style.cursor = mode;
  1375. }
  1376. };
  1377. /**
  1378. * Dispatches an event on the display object that was interacted with.
  1379. * @param displayObject - the display object in question
  1380. * @param eventString - the name of the event (e.g, mousedown)
  1381. * @param eventData - the event data object
  1382. */
  1383. InteractionManager.prototype.dispatchEvent = function (displayObject, eventString, eventData) {
  1384. // Even if the event was stopped, at least dispatch any remaining events
  1385. // for the same display object.
  1386. if (!eventData.stopPropagationHint || displayObject === eventData.stopsPropagatingAt) {
  1387. eventData.currentTarget = displayObject;
  1388. eventData.type = eventString;
  1389. displayObject.emit(eventString, eventData);
  1390. if (displayObject[eventString]) {
  1391. displayObject[eventString](eventData);
  1392. }
  1393. }
  1394. };
  1395. /**
  1396. * Puts a event on a queue to be dispatched later. This is used to guarantee correct
  1397. * ordering of over/out events.
  1398. * @param displayObject - the display object in question
  1399. * @param eventString - the name of the event (e.g, mousedown)
  1400. * @param eventData - the event data object
  1401. */
  1402. InteractionManager.prototype.delayDispatchEvent = function (displayObject, eventString, eventData) {
  1403. this.delayedEvents.push({ displayObject: displayObject, eventString: eventString, eventData: eventData });
  1404. };
  1405. /**
  1406. * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The
  1407. * resulting value is stored in the point. This takes into account the fact that the DOM
  1408. * element could be scaled and positioned anywhere on the screen.
  1409. * @param point - the point that the result will be stored in
  1410. * @param x - the x coord of the position to map
  1411. * @param y - the y coord of the position to map
  1412. */
  1413. InteractionManager.prototype.mapPositionToPoint = function (point, x, y) {
  1414. var rect;
  1415. // IE 11 fix
  1416. if (!this.interactionDOMElement.parentElement) {
  1417. rect = {
  1418. x: 0,
  1419. y: 0,
  1420. width: this.interactionDOMElement.width,
  1421. height: this.interactionDOMElement.height,
  1422. left: 0,
  1423. top: 0
  1424. };
  1425. }
  1426. else {
  1427. rect = this.interactionDOMElement.getBoundingClientRect();
  1428. }
  1429. var resolutionMultiplier = 1.0 / this.resolution;
  1430. point.x = ((x - rect.left) * (this.interactionDOMElement.width / rect.width)) * resolutionMultiplier;
  1431. point.y = ((y - rect.top) * (this.interactionDOMElement.height / rect.height)) * resolutionMultiplier;
  1432. };
  1433. /**
  1434. * This function is provides a neat way of crawling through the scene graph and running a
  1435. * specified function on all interactive objects it finds. It will also take care of hit
  1436. * testing the interactive objects and passes the hit across in the function.
  1437. * @protected
  1438. * @param interactionEvent - event containing the point that
  1439. * is tested for collision
  1440. * @param displayObject - the displayObject
  1441. * that will be hit test (recursively crawls its children)
  1442. * @param func - the function that will be called on each interactive object. The
  1443. * interactionEvent, displayObject and hit will be passed to the function
  1444. * @param hitTest - indicates whether we want to calculate hits
  1445. * or just iterate through all interactive objects
  1446. */
  1447. InteractionManager.prototype.processInteractive = function (interactionEvent, displayObject, func, hitTest) {
  1448. var hit = this.search.findHit(interactionEvent, displayObject, func, hitTest);
  1449. var delayedEvents = this.delayedEvents;
  1450. if (!delayedEvents.length) {
  1451. return hit;
  1452. }
  1453. // Reset the propagation hint, because we start deeper in the tree again.
  1454. interactionEvent.stopPropagationHint = false;
  1455. var delayedLen = delayedEvents.length;
  1456. this.delayedEvents = [];
  1457. for (var i = 0; i < delayedLen; i++) {
  1458. var _a = delayedEvents[i], displayObject_1 = _a.displayObject, eventString = _a.eventString, eventData = _a.eventData;
  1459. // When we reach the object we wanted to stop propagating at,
  1460. // set the propagation hint.
  1461. if (eventData.stopsPropagatingAt === displayObject_1) {
  1462. eventData.stopPropagationHint = true;
  1463. }
  1464. this.dispatchEvent(displayObject_1, eventString, eventData);
  1465. }
  1466. return hit;
  1467. };
  1468. /**
  1469. * Is called when the pointer button is pressed down on the renderer element
  1470. * @param originalEvent - The DOM event of a pointer button being pressed down
  1471. */
  1472. InteractionManager.prototype.onPointerDown = function (originalEvent) {
  1473. // if we support touch events, then only use those for touch events, not pointer events
  1474. if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')
  1475. { return; }
  1476. var events = this.normalizeToPointerData(originalEvent);
  1477. /*
  1478. * No need to prevent default on natural pointer events, as there are no side effects
  1479. * Normalized events, however, may have the double mousedown/touchstart issue on the native android browser,
  1480. * so still need to be prevented.
  1481. */
  1482. // Guaranteed that there will be at least one event in events, and all events must have the same pointer type
  1483. if (this.autoPreventDefault && events[0].isNormalized) {
  1484. var cancelable = originalEvent.cancelable || !('cancelable' in originalEvent);
  1485. if (cancelable) {
  1486. originalEvent.preventDefault();
  1487. }
  1488. }
  1489. var eventLen = events.length;
  1490. for (var i = 0; i < eventLen; i++) {
  1491. var event = events[i];
  1492. var interactionData = this.getInteractionDataForPointerId(event);
  1493. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
  1494. interactionEvent.data.originalEvent = originalEvent;
  1495. this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerDown, true);
  1496. this.emit('pointerdown', interactionEvent);
  1497. if (event.pointerType === 'touch') {
  1498. this.emit('touchstart', interactionEvent);
  1499. }
  1500. // emit a mouse event for "pen" pointers, the way a browser would emit a fallback event
  1501. else if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
  1502. var isRightButton = event.button === 2;
  1503. this.emit(isRightButton ? 'rightdown' : 'mousedown', this.eventData);
  1504. }
  1505. }
  1506. };
  1507. /**
  1508. * Processes the result of the pointer down check and dispatches the event if need be
  1509. * @param interactionEvent - The interaction event wrapping the DOM event
  1510. * @param displayObject - The display object that was tested
  1511. * @param hit - the result of the hit test on the display object
  1512. */
  1513. InteractionManager.prototype.processPointerDown = function (interactionEvent, displayObject, hit) {
  1514. var data = interactionEvent.data;
  1515. var id = interactionEvent.data.identifier;
  1516. if (hit) {
  1517. if (!displayObject.trackedPointers[id]) {
  1518. displayObject.trackedPointers[id] = new InteractionTrackingData(id);
  1519. }
  1520. this.dispatchEvent(displayObject, 'pointerdown', interactionEvent);
  1521. if (data.pointerType === 'touch') {
  1522. this.dispatchEvent(displayObject, 'touchstart', interactionEvent);
  1523. }
  1524. else if (data.pointerType === 'mouse' || data.pointerType === 'pen') {
  1525. var isRightButton = data.button === 2;
  1526. if (isRightButton) {
  1527. displayObject.trackedPointers[id].rightDown = true;
  1528. }
  1529. else {
  1530. displayObject.trackedPointers[id].leftDown = true;
  1531. }
  1532. this.dispatchEvent(displayObject, isRightButton ? 'rightdown' : 'mousedown', interactionEvent);
  1533. }
  1534. }
  1535. };
  1536. /**
  1537. * Is called when the pointer button is released on the renderer element
  1538. * @param originalEvent - The DOM event of a pointer button being released
  1539. * @param cancelled - true if the pointer is cancelled
  1540. * @param func - Function passed to {@link processInteractive}
  1541. */
  1542. InteractionManager.prototype.onPointerComplete = function (originalEvent, cancelled, func) {
  1543. var events = this.normalizeToPointerData(originalEvent);
  1544. var eventLen = events.length;
  1545. // if the event wasn't targeting our canvas, then consider it to be pointerupoutside
  1546. // in all cases (unless it was a pointercancel)
  1547. var target = originalEvent.target;
  1548. // if in shadow DOM use composedPath to access target
  1549. if (originalEvent.composedPath && originalEvent.composedPath().length > 0) {
  1550. target = originalEvent.composedPath()[0];
  1551. }
  1552. var eventAppend = target !== this.interactionDOMElement ? 'outside' : '';
  1553. for (var i = 0; i < eventLen; i++) {
  1554. var event = events[i];
  1555. var interactionData = this.getInteractionDataForPointerId(event);
  1556. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
  1557. interactionEvent.data.originalEvent = originalEvent;
  1558. // perform hit testing for events targeting our canvas or cancel events
  1559. this.processInteractive(interactionEvent, this.lastObjectRendered, func, cancelled || !eventAppend);
  1560. this.emit(cancelled ? 'pointercancel' : "pointerup" + eventAppend, interactionEvent);
  1561. if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
  1562. var isRightButton = event.button === 2;
  1563. this.emit(isRightButton ? "rightup" + eventAppend : "mouseup" + eventAppend, interactionEvent);
  1564. }
  1565. else if (event.pointerType === 'touch') {
  1566. this.emit(cancelled ? 'touchcancel' : "touchend" + eventAppend, interactionEvent);
  1567. this.releaseInteractionDataForPointerId(event.pointerId);
  1568. }
  1569. }
  1570. };
  1571. /**
  1572. * Is called when the pointer button is cancelled
  1573. * @param event - The DOM event of a pointer button being released
  1574. */
  1575. InteractionManager.prototype.onPointerCancel = function (event) {
  1576. // if we support touch events, then only use those for touch events, not pointer events
  1577. if (this.supportsTouchEvents && event.pointerType === 'touch')
  1578. { return; }
  1579. this.onPointerComplete(event, true, this.processPointerCancel);
  1580. };
  1581. /**
  1582. * Processes the result of the pointer cancel check and dispatches the event if need be
  1583. * @param interactionEvent - The interaction event wrapping the DOM event
  1584. * @param displayObject - The display object that was tested
  1585. */
  1586. InteractionManager.prototype.processPointerCancel = function (interactionEvent, displayObject) {
  1587. var data = interactionEvent.data;
  1588. var id = interactionEvent.data.identifier;
  1589. if (displayObject.trackedPointers[id] !== undefined) {
  1590. delete displayObject.trackedPointers[id];
  1591. this.dispatchEvent(displayObject, 'pointercancel', interactionEvent);
  1592. if (data.pointerType === 'touch') {
  1593. this.dispatchEvent(displayObject, 'touchcancel', interactionEvent);
  1594. }
  1595. }
  1596. };
  1597. /**
  1598. * Is called when the pointer button is released on the renderer element
  1599. * @param event - The DOM event of a pointer button being released
  1600. */
  1601. InteractionManager.prototype.onPointerUp = function (event) {
  1602. // if we support touch events, then only use those for touch events, not pointer events
  1603. if (this.supportsTouchEvents && event.pointerType === 'touch')
  1604. { return; }
  1605. this.onPointerComplete(event, false, this.processPointerUp);
  1606. };
  1607. /**
  1608. * Processes the result of the pointer up check and dispatches the event if need be
  1609. * @param interactionEvent - The interaction event wrapping the DOM event
  1610. * @param displayObject - The display object that was tested
  1611. * @param hit - the result of the hit test on the display object
  1612. */
  1613. InteractionManager.prototype.processPointerUp = function (interactionEvent, displayObject, hit) {
  1614. var data = interactionEvent.data;
  1615. var id = interactionEvent.data.identifier;
  1616. var trackingData = displayObject.trackedPointers[id];
  1617. var isTouch = data.pointerType === 'touch';
  1618. var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');
  1619. // need to track mouse down status in the mouse block so that we can emit
  1620. // event in a later block
  1621. var isMouseTap = false;
  1622. // Mouse only
  1623. if (isMouse) {
  1624. var isRightButton = data.button === 2;
  1625. var flags = InteractionTrackingData.FLAGS;
  1626. var test = isRightButton ? flags.RIGHT_DOWN : flags.LEFT_DOWN;
  1627. var isDown = trackingData !== undefined && (trackingData.flags & test);
  1628. if (hit) {
  1629. this.dispatchEvent(displayObject, isRightButton ? 'rightup' : 'mouseup', interactionEvent);
  1630. if (isDown) {
  1631. this.dispatchEvent(displayObject, isRightButton ? 'rightclick' : 'click', interactionEvent);
  1632. // because we can confirm that the mousedown happened on this object, flag for later emit of pointertap
  1633. isMouseTap = true;
  1634. }
  1635. }
  1636. else if (isDown) {
  1637. this.dispatchEvent(displayObject, isRightButton ? 'rightupoutside' : 'mouseupoutside', interactionEvent);
  1638. }
  1639. // update the down state of the tracking data
  1640. if (trackingData) {
  1641. if (isRightButton) {
  1642. trackingData.rightDown = false;
  1643. }
  1644. else {
  1645. trackingData.leftDown = false;
  1646. }
  1647. }
  1648. }
  1649. // Pointers and Touches, and Mouse
  1650. if (hit) {
  1651. this.dispatchEvent(displayObject, 'pointerup', interactionEvent);
  1652. if (isTouch)
  1653. { this.dispatchEvent(displayObject, 'touchend', interactionEvent); }
  1654. if (trackingData) {
  1655. // emit pointertap if not a mouse, or if the mouse block decided it was a tap
  1656. if (!isMouse || isMouseTap) {
  1657. this.dispatchEvent(displayObject, 'pointertap', interactionEvent);
  1658. }
  1659. if (isTouch) {
  1660. this.dispatchEvent(displayObject, 'tap', interactionEvent);
  1661. // touches are no longer over (if they ever were) when we get the touchend
  1662. // so we should ensure that we don't keep pretending that they are
  1663. trackingData.over = false;
  1664. }
  1665. }
  1666. }
  1667. else if (trackingData) {
  1668. this.dispatchEvent(displayObject, 'pointerupoutside', interactionEvent);
  1669. if (isTouch)
  1670. { this.dispatchEvent(displayObject, 'touchendoutside', interactionEvent); }
  1671. }
  1672. // Only remove the tracking data if there is no over/down state still associated with it
  1673. if (trackingData && trackingData.none) {
  1674. delete displayObject.trackedPointers[id];
  1675. }
  1676. };
  1677. /**
  1678. * Is called when the pointer moves across the renderer element
  1679. * @param originalEvent - The DOM event of a pointer moving
  1680. */
  1681. InteractionManager.prototype.onPointerMove = function (originalEvent) {
  1682. // if we support touch events, then only use those for touch events, not pointer events
  1683. if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')
  1684. { return; }
  1685. var events = this.normalizeToPointerData(originalEvent);
  1686. if (events[0].pointerType === 'mouse' || events[0].pointerType === 'pen') {
  1687. this._didMove = true;
  1688. this.cursor = null;
  1689. }
  1690. var eventLen = events.length;
  1691. for (var i = 0; i < eventLen; i++) {
  1692. var event = events[i];
  1693. var interactionData = this.getInteractionDataForPointerId(event);
  1694. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
  1695. interactionEvent.data.originalEvent = originalEvent;
  1696. this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerMove, true);
  1697. this.emit('pointermove', interactionEvent);
  1698. if (event.pointerType === 'touch')
  1699. { this.emit('touchmove', interactionEvent); }
  1700. if (event.pointerType === 'mouse' || event.pointerType === 'pen')
  1701. { this.emit('mousemove', interactionEvent); }
  1702. }
  1703. if (events[0].pointerType === 'mouse') {
  1704. this.setCursorMode(this.cursor);
  1705. // TODO BUG for parents interactive object (border order issue)
  1706. }
  1707. };
  1708. /**
  1709. * Processes the result of the pointer move check and dispatches the event if need be
  1710. * @param interactionEvent - The interaction event wrapping the DOM event
  1711. * @param displayObject - The display object that was tested
  1712. * @param hit - the result of the hit test on the display object
  1713. */
  1714. InteractionManager.prototype.processPointerMove = function (interactionEvent, displayObject, hit) {
  1715. var data = interactionEvent.data;
  1716. var isTouch = data.pointerType === 'touch';
  1717. var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');
  1718. if (isMouse) {
  1719. this.processPointerOverOut(interactionEvent, displayObject, hit);
  1720. }
  1721. if (!this.moveWhenInside || hit) {
  1722. this.dispatchEvent(displayObject, 'pointermove', interactionEvent);
  1723. if (isTouch)
  1724. { this.dispatchEvent(displayObject, 'touchmove', interactionEvent); }
  1725. if (isMouse)
  1726. { this.dispatchEvent(displayObject, 'mousemove', interactionEvent); }
  1727. }
  1728. };
  1729. /**
  1730. * Is called when the pointer is moved out of the renderer element
  1731. * @private
  1732. * @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out
  1733. */
  1734. InteractionManager.prototype.onPointerOut = function (originalEvent) {
  1735. // if we support touch events, then only use those for touch events, not pointer events
  1736. if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')
  1737. { return; }
  1738. var events = this.normalizeToPointerData(originalEvent);
  1739. // Only mouse and pointer can call onPointerOut, so events will always be length 1
  1740. var event = events[0];
  1741. if (event.pointerType === 'mouse') {
  1742. this.mouseOverRenderer = false;
  1743. this.setCursorMode(null);
  1744. }
  1745. var interactionData = this.getInteractionDataForPointerId(event);
  1746. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
  1747. interactionEvent.data.originalEvent = event;
  1748. this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerOverOut, false);
  1749. this.emit('pointerout', interactionEvent);
  1750. if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
  1751. this.emit('mouseout', interactionEvent);
  1752. }
  1753. else {
  1754. // we can get touchleave events after touchend, so we want to make sure we don't
  1755. // introduce memory leaks
  1756. this.releaseInteractionDataForPointerId(interactionData.identifier);
  1757. }
  1758. };
  1759. /**
  1760. * Processes the result of the pointer over/out check and dispatches the event if need be.
  1761. * @param interactionEvent - The interaction event wrapping the DOM event
  1762. * @param displayObject - The display object that was tested
  1763. * @param hit - the result of the hit test on the display object
  1764. */
  1765. InteractionManager.prototype.processPointerOverOut = function (interactionEvent, displayObject, hit) {
  1766. var data = interactionEvent.data;
  1767. var id = interactionEvent.data.identifier;
  1768. var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');
  1769. var trackingData = displayObject.trackedPointers[id];
  1770. // if we just moused over the display object, then we need to track that state
  1771. if (hit && !trackingData) {
  1772. trackingData = displayObject.trackedPointers[id] = new InteractionTrackingData(id);
  1773. }
  1774. if (trackingData === undefined)
  1775. { return; }
  1776. if (hit && this.mouseOverRenderer) {
  1777. if (!trackingData.over) {
  1778. trackingData.over = true;
  1779. this.delayDispatchEvent(displayObject, 'pointerover', interactionEvent);
  1780. if (isMouse) {
  1781. this.delayDispatchEvent(displayObject, 'mouseover', interactionEvent);
  1782. }
  1783. }
  1784. // only change the cursor if it has not already been changed (by something deeper in the
  1785. // display tree)
  1786. if (isMouse && this.cursor === null) {
  1787. this.cursor = displayObject.cursor;
  1788. }
  1789. }
  1790. else if (trackingData.over) {
  1791. trackingData.over = false;
  1792. this.dispatchEvent(displayObject, 'pointerout', this.eventData);
  1793. if (isMouse) {
  1794. this.dispatchEvent(displayObject, 'mouseout', interactionEvent);
  1795. }
  1796. // if there is no mouse down information for the pointer, then it is safe to delete
  1797. if (trackingData.none) {
  1798. delete displayObject.trackedPointers[id];
  1799. }
  1800. }
  1801. };
  1802. /**
  1803. * Is called when the pointer is moved into the renderer element.
  1804. * @param originalEvent - The DOM event of a pointer button being moved into the renderer view.
  1805. */
  1806. InteractionManager.prototype.onPointerOver = function (originalEvent) {
  1807. if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')
  1808. { return; }
  1809. var events = this.normalizeToPointerData(originalEvent);
  1810. // Only mouse and pointer can call onPointerOver, so events will always be length 1
  1811. var event = events[0];
  1812. var interactionData = this.getInteractionDataForPointerId(event);
  1813. var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
  1814. interactionEvent.data.originalEvent = event;
  1815. if (event.pointerType === 'mouse') {
  1816. this.mouseOverRenderer = true;
  1817. }
  1818. this.emit('pointerover', interactionEvent);
  1819. if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
  1820. this.emit('mouseover', interactionEvent);
  1821. }
  1822. };
  1823. /**
  1824. * Get InteractionData for a given pointerId. Store that data as well.
  1825. * @param event - Normalized pointer event, output from normalizeToPointerData.
  1826. * @returns - Interaction data for the given pointer identifier.
  1827. */
  1828. InteractionManager.prototype.getInteractionDataForPointerId = function (event) {
  1829. var pointerId = event.pointerId;
  1830. var interactionData;
  1831. if (pointerId === MOUSE_POINTER_ID || event.pointerType === 'mouse') {
  1832. interactionData = this.mouse;
  1833. }
  1834. else if (this.activeInteractionData[pointerId]) {
  1835. interactionData = this.activeInteractionData[pointerId];
  1836. }
  1837. else {
  1838. interactionData = this.interactionDataPool.pop() || new InteractionData();
  1839. interactionData.identifier = pointerId;
  1840. this.activeInteractionData[pointerId] = interactionData;
  1841. }
  1842. // copy properties from the event, so that we can make sure that touch/pointer specific
  1843. // data is available
  1844. interactionData.copyEvent(event);
  1845. return interactionData;
  1846. };
  1847. /**
  1848. * Return unused InteractionData to the pool, for a given pointerId
  1849. * @param pointerId - Identifier from a pointer event
  1850. */
  1851. InteractionManager.prototype.releaseInteractionDataForPointerId = function (pointerId) {
  1852. var interactionData = this.activeInteractionData[pointerId];
  1853. if (interactionData) {
  1854. delete this.activeInteractionData[pointerId];
  1855. interactionData.reset();
  1856. this.interactionDataPool.push(interactionData);
  1857. }
  1858. };
  1859. /**
  1860. * Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData
  1861. * @param interactionEvent - The event to be configured
  1862. * @param pointerEvent - The DOM event that will be paired with the InteractionEvent
  1863. * @param interactionData - The InteractionData that will be paired
  1864. * with the InteractionEvent
  1865. * @returns - the interaction event that was passed in
  1866. */
  1867. InteractionManager.prototype.configureInteractionEventForDOMEvent = function (interactionEvent, pointerEvent, interactionData) {
  1868. interactionEvent.data = interactionData;
  1869. this.mapPositionToPoint(interactionData.global, pointerEvent.clientX, pointerEvent.clientY);
  1870. // Not really sure why this is happening, but it's how a previous version handled things
  1871. if (pointerEvent.pointerType === 'touch') {
  1872. pointerEvent.globalX = interactionData.global.x;
  1873. pointerEvent.globalY = interactionData.global.y;
  1874. }
  1875. interactionData.originalEvent = pointerEvent;
  1876. interactionEvent.reset();
  1877. return interactionEvent;
  1878. };
  1879. /**
  1880. * Ensures that the original event object contains all data that a regular pointer event would have
  1881. * @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event
  1882. * @returns - An array containing a single normalized pointer event, in the case of a pointer
  1883. * or mouse event, or a multiple normalized pointer events if there are multiple changed touches
  1884. */
  1885. InteractionManager.prototype.normalizeToPointerData = function (event) {
  1886. var normalizedEvents = [];
  1887. if (this.supportsTouchEvents && event instanceof TouchEvent) {
  1888. for (var i = 0, li = event.changedTouches.length; i < li; i++) {
  1889. var touch = event.changedTouches[i];
  1890. if (typeof touch.button === 'undefined')
  1891. { touch.button = event.touches.length ? 1 : 0; }
  1892. if (typeof touch.buttons === 'undefined')
  1893. { touch.buttons = event.touches.length ? 1 : 0; }
  1894. if (typeof touch.isPrimary === 'undefined') {
  1895. touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
  1896. }
  1897. if (typeof touch.width === 'undefined')
  1898. { touch.width = touch.radiusX || 1; }
  1899. if (typeof touch.height === 'undefined')
  1900. { touch.height = touch.radiusY || 1; }
  1901. if (typeof touch.tiltX === 'undefined')
  1902. { touch.tiltX = 0; }
  1903. if (typeof touch.tiltY === 'undefined')
  1904. { touch.tiltY = 0; }
  1905. if (typeof touch.pointerType === 'undefined')
  1906. { touch.pointerType = 'touch'; }
  1907. if (typeof touch.pointerId === 'undefined')
  1908. { touch.pointerId = touch.identifier || 0; }
  1909. if (typeof touch.pressure === 'undefined')
  1910. { touch.pressure = touch.force || 0.5; }
  1911. if (typeof touch.twist === 'undefined')
  1912. { touch.twist = 0; }
  1913. if (typeof touch.tangentialPressure === 'undefined')
  1914. { touch.tangentialPressure = 0; }
  1915. // TODO: Remove these, as layerX/Y is not a standard, is deprecated, has uneven
  1916. // support, and the fill ins are not quite the same
  1917. // offsetX/Y might be okay, but is not the same as clientX/Y when the canvas's top
  1918. // left is not 0,0 on the page
  1919. if (typeof touch.layerX === 'undefined')
  1920. { touch.layerX = touch.offsetX = touch.clientX; }
  1921. if (typeof touch.layerY === 'undefined')
  1922. { touch.layerY = touch.offsetY = touch.clientY; }
  1923. // mark the touch as normalized, just so that we know we did it
  1924. touch.isNormalized = true;
  1925. normalizedEvents.push(touch);
  1926. }
  1927. }
  1928. // apparently PointerEvent subclasses MouseEvent, so yay
  1929. else if (!globalThis.MouseEvent
  1930. || (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent)))) {
  1931. var tempEvent = event;
  1932. if (typeof tempEvent.isPrimary === 'undefined')
  1933. { tempEvent.isPrimary = true; }
  1934. if (typeof tempEvent.width === 'undefined')
  1935. { tempEvent.width = 1; }
  1936. if (typeof tempEvent.height === 'undefined')
  1937. { tempEvent.height = 1; }
  1938. if (typeof tempEvent.tiltX === 'undefined')
  1939. { tempEvent.tiltX = 0; }
  1940. if (typeof tempEvent.tiltY === 'undefined')
  1941. { tempEvent.tiltY = 0; }
  1942. if (typeof tempEvent.pointerType === 'undefined')
  1943. { tempEvent.pointerType = 'mouse'; }
  1944. if (typeof tempEvent.pointerId === 'undefined')
  1945. { tempEvent.pointerId = MOUSE_POINTER_ID; }
  1946. if (typeof tempEvent.pressure === 'undefined')
  1947. { tempEvent.pressure = 0.5; }
  1948. if (typeof tempEvent.twist === 'undefined')
  1949. { tempEvent.twist = 0; }
  1950. if (typeof tempEvent.tangentialPressure === 'undefined')
  1951. { tempEvent.tangentialPressure = 0; }
  1952. // mark the mouse event as normalized, just so that we know we did it
  1953. tempEvent.isNormalized = true;
  1954. normalizedEvents.push(tempEvent);
  1955. }
  1956. else {
  1957. normalizedEvents.push(event);
  1958. }
  1959. return normalizedEvents;
  1960. };
  1961. /** Destroys the interaction manager. */
  1962. InteractionManager.prototype.destroy = function () {
  1963. this.removeEvents();
  1964. this.removeTickerListener();
  1965. this.removeAllListeners();
  1966. this.renderer = null;
  1967. this.mouse = null;
  1968. this.eventData = null;
  1969. this.interactionDOMElement = null;
  1970. this.onPointerDown = null;
  1971. this.processPointerDown = null;
  1972. this.onPointerUp = null;
  1973. this.processPointerUp = null;
  1974. this.onPointerCancel = null;
  1975. this.processPointerCancel = null;
  1976. this.onPointerMove = null;
  1977. this.processPointerMove = null;
  1978. this.onPointerOut = null;
  1979. this.processPointerOverOut = null;
  1980. this.onPointerOver = null;
  1981. this.search = null;
  1982. };
  1983. /** @ignore */
  1984. InteractionManager.extension = {
  1985. name: 'interaction',
  1986. type: [
  1987. core.ExtensionType.RendererPlugin,
  1988. core.ExtensionType.CanvasRendererPlugin ],
  1989. };
  1990. return InteractionManager;
  1991. }(utils.EventEmitter));
  1992. exports.InteractionData = InteractionData;
  1993. exports.InteractionEvent = InteractionEvent;
  1994. exports.InteractionManager = InteractionManager;
  1995. exports.InteractionTrackingData = InteractionTrackingData;
  1996. exports.interactiveTarget = interactiveTarget;
  1997. Object.defineProperty(exports, '__esModule', { value: true });
  1998. return exports;
  1999. })({}, PIXI, PIXI, PIXI, PIXI.utils, PIXI);
  2000. Object.assign(this.PIXI, _pixi_interaction);
  2001. //# sourceMappingURL=interaction.js.map