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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | 1x 1x 1x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 1x 3x 3x 3x 3x 3x 3x 3x 2x 2x 3x 1x 1x 3x 3x 3x 1x 1x 1107x 1107x 6x 1107x 1107x 1107x 13x 7x 7x 13x 6x 1107x 1x 17x 17x 1x 1x 1x 1x 10549x 10549x 10549x 10549x 10549x 2x 2x 2x 2x 2x 2x 10549x 10549x 1x 1x 1908x 1908x 144x 144x 1188x 1188x 1188x 1188x 1188x 1188x 1188x 1188x 35x 35x 35x 35x 35x 144x 144x 144x 1908x 1908x 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 { Base } from '~/straps'; /** * @name Emitter * @namespace * @private */ export const Emitter = { on: function (type, func) { // If an object literal is passed, attach all callbacks defined in it if (typeof type !== 'string') { Base.each( type, function (value, key) { this.on(key, value); }, this ); } else { var types = this._eventTypes, entry = types && types[type], handlers = (this._callbacks = this._callbacks || {}); handlers = handlers[type] = handlers[type] || []; if (handlers.indexOf(func) === -1) { // Not added yet, add now. handlers.push(func); // See if this is the first handler that we're attaching, // and call install if defined. if (entry && entry.install && handlers.length === 1) entry.install.call(this, type); } } return this; }, off: function (type, func) { // If an object literal is passed, detach all callbacks defined in it if (typeof type !== 'string') { Base.each( type, function (value, key) { this.off(key, value); }, this ); return; } var types = this._eventTypes, entry = types && types[type], handlers = this._callbacks && this._callbacks[type], index; if (handlers) { // See if this is the last handler that we're detaching (or if we // are detaching all handlers), and call uninstall if defined. if (!func || ((index = handlers.indexOf(func)) !== -1 && handlers.length === 1)) { if (entry && entry.uninstall) entry.uninstall.call(this, type); // Delete handlers entry again, so responds() returns false. delete this._callbacks[type]; } else if (index !== -1) { // Just remove this one handler handlers.splice(index, 1); } } return this; }, once: function (type, func) { return this.on(type, function handler() { func.apply(this, arguments); this.off(type, handler); }); }, emit: function (type, event) { // Returns true if any events were emitted, false otherwise. var handlers = this._callbacks && this._callbacks[type]; if (!handlers) return false; var args = Base.slice(arguments, 1), // Set the current target to `this` if the event object defines // #target but not #currentTarget. setTarget = event && event.target && !event.currentTarget; // Create a clone of the handlers list so changes caused by on / off // won't throw us off track here: handlers = handlers.slice(); if (setTarget) event.currentTarget = this; for (var i = 0, l = handlers.length; i < l; i++) { if (handlers[i].apply(this, args) == false) { // If the handler returns false, prevent the default behavior // and stop propagation of the event by calling stop() if (event && event.stop) event.stop(); // Stop propagation right now! break; } } if (setTarget) delete event.currentTarget; return true; }, responds: function (type) { return !!(this._callbacks && this._callbacks[type]); }, // Keep deprecated methods around from previous Callback interface. attach: '#on', detach: '#off', fire: '#emit', _installEvents: function (install) { var types = this._eventTypes, handlers = this._callbacks, key = install ? 'install' : 'uninstall'; if (types) { for (var type in handlers) { if (handlers[type].length > 0) { var entry = types[type], func = entry && entry[key]; if (func) func.call(this, type); } } } }, statics: { // Override inject() so that sub-classes automatically add the accessors // for the event handler functions (e.g. #onMouseDown) for each property // NOTE: This needs to be defined in the first injection scope, as for // simplicity, we don't loop through all of them here. inject: function inject(src) { var events = src._events; if (events) { // events can either be an object literal or an array of // strings describing the on*-names. // We need to map lowercased event types to the event // entries represented by these on*-names in _events. var types = {}; Base.each(events, function (entry, key) { var isString = typeof entry === 'string', name = isString ? entry : key, part = Base.capitalize(name), type = name.substring(2).toLowerCase(); // Map the event type name to the event entry. types[type] = isString ? {} : entry; // Create getters and setters for the property // with the on*-name name: name = '_' + name; src['get' + part] = function () { return this[name]; }; src['set' + part] = function (func) { // Detach the previous event, if there was one. var prev = this[name]; if (prev) this.off(type, prev); if (func) this.on(type, func); this[name] = func; }; }); src._eventTypes = types; } return (inject as any).base.apply(this, arguments); }, }, }; |