Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1x 1x 1x 1x 1x 719x 719x 956x 956x 956x 1654x 1654x 1654x 1654x 1654x 956x 719x 719x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 18x 18x 1x 1x 1x 1x 1x 1x 36x 36x 36x 36x 36x 36x 1x 1x | /* * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey * http://juerglehni.com/ & https://puckey.studio/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. */ // TODO: remove eslint-disable comment and deal with errors over time /* eslint-disable */ import { ref } from '~/globals'; import { Point } from '~/basic/Point'; import { DomElement } from './DomElement'; /** * @name DomEvent * @namespace * @private */ export const DomEvent = /** @lends DomEvent */ { add: function (el, events) { // Do not fail if el is not defined, that way we can keep the code that // should not fail in web-workers to a minimum. if (el) { for (var type in events) { var func = events[type], parts = type.split(/[\s,]+/g); for (var i = 0, l = parts.length; i < l; i++) { var name = parts[i]; // For touchstart/touchmove events on document, we need to // explicitly declare that the event is not passive (can be // prevented). Otherwise chrome browser would ignore // `event.preventDefault()` calls and omit warnings. // See #1501 and: // https://www.chromestatus.com/features/5093566007214080 var options = el === globalThis.document && (name === 'touchstart' || name === 'touchmove') ? { passive: false } : false; el.addEventListener(name, func, options); } } } }, remove: function (el, events) { // See DomEvent.add() for an explanation of this check: if (el) { for (var type in events) { var func = events[type], parts = type.split(/[\s,]+/g); for (var i = 0, l = parts.length; i < l; i++) el.removeEventListener(parts[i], func, false); } } }, getPoint: function (event) { var pos = event.targetTouches ? event.targetTouches.length ? event.targetTouches[0] : event.changedTouches[0] : event; return new Point( pos.pageX || pos.clientX + globalThis.document.documentElement.scrollLeft, pos.pageY || pos.clientY + globalThis.document.documentElement.scrollTop ); }, getTarget: function (event) { return event.target || event.srcElement; }, getRelatedTarget: function (event) { return event.relatedTarget || event.toElement; }, getOffset: function (event, target) { // Remove target offsets from page coordinates return DomEvent.getPoint(event).subtract(DomElement.getOffset(target || DomEvent.getTarget(event))); }, }; // @ts-expect-error = Property 'requestAnimationFrame' does not exist on type DomEvent.requestAnimationFrame = new (function () { var nativeRequest = DomElement.getPrefixed(globalThis.window, 'requestAnimationFrame'), requested = false, callbacks = [], timer; function handleCallbacks() { // Make a local references to the current callbacks array and set // callbacks to a new empty array, so it can collect the functions for // the new requests. var functions = callbacks; callbacks = []; // Call the collected callback functions. for (var i = 0, l = functions.length; i < l; i++) functions[i](); // Now see if the above calls have collected new callbacks. Keep // requesting new frames as long as we have callbacks. // @ts-expect-error = Type 'number' is not assignable to type 'boolean' requested = nativeRequest && callbacks.length; if (requested) nativeRequest(handleCallbacks); } return function (callback) { // Add to the list of callbacks to be called in the next animation // frame. callbacks.push(callback); if (nativeRequest) { // Handle animation natively. We only need to request the frame // once for all collected callbacks. if (!requested) { nativeRequest(handleCallbacks); requested = true; } } else if (!timer) { // Install interval timer that checks all callbacks. This // results in faster animations than repeatedly installing // timeout timers. timer = setInterval(handleCallbacks, 1000 / 60); } }; })(); ref.DomEvent = DomEvent; |