Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/konva/lib/Node.js

    rd565449 r0c6b92a  
    88const DragAndDrop_1 = require("./DragAndDrop");
    99const Validators_1 = require("./Validators");
    10 var ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
     10const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
    1111    'xChange.konva',
    1212    'yChange.konva',
     
    5757    }
    5858    _getCache(attr, privateGetter) {
    59         var cache = this._cache.get(attr);
    60         var isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
    61         var invalid = cache === undefined || (isTransform && cache.dirty === true);
     59        let cache = this._cache.get(attr);
     60        const isTransform = attr === TRANSFORM || attr === ABSOLUTE_TRANSFORM;
     61        const invalid = cache === undefined || (isTransform && cache.dirty === true);
    6262        if (invalid) {
    6363            cache = privateGetter.call(this);
     
    9696    }
    9797    cache(config) {
    98         var conf = config || {};
    99         var rect = {};
     98        const conf = config || {};
     99        let rect = {};
    100100        if (conf.x === undefined ||
    101101            conf.y === undefined ||
     
    107107            });
    108108        }
    109         var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
     109        let width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
    110110        if (!width || !height) {
    111111            Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
     
    118118        x -= offset;
    119119        y -= offset;
    120         var cachedSceneCanvas = new Canvas_1.SceneCanvas({
     120        const cachedSceneCanvas = new Canvas_1.SceneCanvas({
    121121            pixelRatio: pixelRatio,
    122122            width: width,
     
    179179    }
    180180    _transformedRect(rect, top) {
    181         var points = [
     181        const points = [
    182182            { x: rect.x, y: rect.y },
    183183            { x: rect.x + rect.width, y: rect.y },
     
    185185            { x: rect.x, y: rect.y + rect.height },
    186186        ];
    187         var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
    188         var trans = this.getAbsoluteTransform(top);
     187        let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
     188        const trans = this.getAbsoluteTransform(top);
    189189        points.forEach(function (point) {
    190             var transformed = trans.point(point);
     190            const transformed = trans.point(point);
    191191            if (minX === undefined) {
    192192                minX = maxX = transformed.x;
     
    211211        const canvasCache = this._getCanvasCache();
    212212        context.translate(canvasCache.x, canvasCache.y);
    213         var cacheCanvas = this._getCachedSceneCanvas();
    214         var ratio = cacheCanvas.pixelRatio;
     213        const cacheCanvas = this._getCachedSceneCanvas();
     214        const ratio = cacheCanvas.pixelRatio;
    215215        context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);
    216216        context.restore();
    217217    }
    218218    _drawCachedHitCanvas(context) {
    219         var canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
     219        const canvasCache = this._getCanvasCache(), hitCanvas = canvasCache.hit;
    220220        context.save();
    221221        context.translate(canvasCache.x, canvasCache.y);
     
    224224    }
    225225    _getCachedSceneCanvas() {
    226         var filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
     226        let filters = this.filters(), cachedCanvas = this._getCanvasCache(), sceneCanvas = cachedCanvas.scene, filterCanvas = cachedCanvas.filter, filterContext = filterCanvas.getContext(), len, imageData, n, filter;
    227227        if (filters) {
    228228            if (!this._filterUpToDate) {
    229                 var ratio = sceneCanvas.pixelRatio;
     229                const ratio = sceneCanvas.pixelRatio;
    230230                filterCanvas.setSize(sceneCanvas.width / sceneCanvas.pixelRatio, sceneCanvas.height / sceneCanvas.pixelRatio);
    231231                try {
     
    262262            return this._delegate.apply(this, arguments);
    263263        }
    264         var events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
     264        let events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
    265265        for (n = 0; n < len; n++) {
    266266            event = events[n];
     
    279279    }
    280280    off(evtStr, callback) {
    281         var events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;
     281        let events = (evtStr || '').split(SPACE), len = events.length, n, t, event, parts, baseEvent, name;
    282282        this._cache && this._cache.delete(ALL_LISTENERS);
    283283        if (!evtStr) {
     
    305305    }
    306306    dispatchEvent(evt) {
    307         var e = {
     307        const e = {
    308308            target: this,
    309309            type: evt.type,
     
    324324    }
    325325    _delegate(event, selector, handler) {
    326         var stopNode = this;
     326        const stopNode = this;
    327327        this.on(event, function (evt) {
    328             var targets = evt.target.findAncestors(selector, true, stopNode);
    329             for (var i = 0; i < targets.length; i++) {
     328            const targets = evt.target.findAncestors(selector, true, stopNode);
     329            for (let i = 0; i < targets.length; i++) {
    330330                evt = Util_1.Util.cloneObject(evt);
    331331                evt.currentTarget = targets[i];
     
    352352    _remove() {
    353353        this._clearCaches();
    354         var parent = this.getParent();
     354        const parent = this.getParent();
    355355        if (parent && parent.children) {
    356356            parent.children.splice(this.index, 1);
     
    365365    }
    366366    getAttr(attr) {
    367         var method = 'get' + Util_1.Util._capitalize(attr);
     367        const method = 'get' + Util_1.Util._capitalize(attr);
    368368        if (Util_1.Util._isFunction(this[method])) {
    369369            return this[method]();
     
    372372    }
    373373    getAncestors() {
    374         var parent = this.getParent(), ancestors = [];
     374        let parent = this.getParent(), ancestors = [];
    375375        while (parent) {
    376376            ancestors.push(parent);
     
    384384    setAttrs(config) {
    385385        this._batchTransformChanges(() => {
    386             var key, method;
     386            let key, method;
    387387            if (!config) {
    388388                return this;
     
    439439            return this._isVisible(top) && this._isListening(top);
    440440        }
    441         var layer = this.getLayer();
    442         var layerUnderDrag = false;
     441        const layer = this.getLayer();
     442        let layerUnderDrag = false;
    443443        DragAndDrop_1.DD._dragElements.forEach((elem) => {
    444444            if (elem.dragStatus !== 'dragging') {
     
    452452            }
    453453        });
    454         var dragSkip = !skipDragCheck &&
     454        const dragSkip = !skipDragCheck &&
    455455            !Global_1.Konva.hitOnDragEnabled &&
    456456            (layerUnderDrag || Global_1.Konva.isTransforming());
     
    469469    }
    470470    getAbsoluteZIndex() {
    471         var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
     471        let depth = this.getDepth(), that = this, index = 0, nodes, len, n, child;
    472472        function addChildren(children) {
    473473            nodes = [];
     
    494494    }
    495495    getDepth() {
    496         var depth = 0, parent = this.parent;
     496        let depth = 0, parent = this.parent;
    497497        while (parent) {
    498498            depth++;
     
    529529            return null;
    530530        }
    531         var pos = stage.getPointerPosition();
     531        const pos = stage.getPointerPosition();
    532532        if (!pos) {
    533533            return null;
    534534        }
    535         var transform = this.getAbsoluteTransform().copy();
     535        const transform = this.getAbsoluteTransform().copy();
    536536        transform.invert();
    537537        return transform.point(pos);
     
    550550            top = true;
    551551        }
    552         var absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();
     552        const absoluteMatrix = this.getAbsoluteTransform(top).getMatrix(), absoluteTransform = new Util_1.Transform(), offset = this.offset();
    553553        absoluteTransform.m = absoluteMatrix.slice();
    554554        absoluteTransform.translate(offset.x, offset.y);
     
    560560        this.attrs.y = y;
    561561        this._clearCache(TRANSFORM);
    562         var it = this._getAbsoluteTransform().copy();
     562        const it = this._getAbsoluteTransform().copy();
    563563        it.invert();
    564564        it.translate(pos.x, pos.y);
     
    574574    }
    575575    _setTransform(trans) {
    576         var key;
     576        let key;
    577577        for (key in trans) {
    578578            this.attrs[key] = trans[key];
     
    580580    }
    581581    _clearTransform() {
    582         var trans = {
     582        const trans = {
    583583            x: this.x(),
    584584            y: this.y(),
     
    603603    }
    604604    move(change) {
    605         var changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
     605        let changeX = change.x, changeY = change.y, x = this.x(), y = this.y();
    606606        if (changeX !== undefined) {
    607607            x += changeX;
     
    614614    }
    615615    _eachAncestorReverse(func, top) {
    616         var family = [], parent = this.getParent(), len, n;
     616        let family = [], parent = this.getParent(), len, n;
    617617        if (top && top._id === this._id) {
    618618            return;
     
    637637            return false;
    638638        }
    639         var index = this.index, len = this.parent.getChildren().length;
     639        const index = this.index, len = this.parent.getChildren().length;
    640640        if (index < len - 1) {
    641641            this.parent.children.splice(index, 1);
     
    651651            return false;
    652652        }
    653         var index = this.index, len = this.parent.getChildren().length;
     653        const index = this.index, len = this.parent.getChildren().length;
    654654        if (index < len - 1) {
    655655            this.parent.children.splice(index, 1);
     
    665665            return false;
    666666        }
    667         var index = this.index;
     667        const index = this.index;
    668668        if (index > 0) {
    669669            this.parent.children.splice(index, 1);
     
    679679            return false;
    680680        }
    681         var index = this.index;
     681        const index = this.index;
    682682        if (index > 0) {
    683683            this.parent.children.splice(index, 1);
     
    700700                '.');
    701701        }
    702         var index = this.index;
     702        const index = this.index;
    703703        this.parent.children.splice(index, 1);
    704704        this.parent.children.splice(zIndex, 0, this);
     
    710710    }
    711711    _getAbsoluteOpacity() {
    712         var absOpacity = this.opacity();
    713         var parent = this.getParent();
     712        let absOpacity = this.opacity();
     713        const parent = this.getParent();
    714714        if (parent && !parent._isUnderCache) {
    715715            absOpacity *= parent.getAbsoluteOpacity();
     
    725725    }
    726726    toObject() {
    727         var attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
     727        let attrs = this.getAttrs(), key, val, getter, defaultValue, nonPlainObject;
    728728        const obj = {
    729729            attrs: {},
     
    754754    }
    755755    findAncestors(selector, includeSelf, stopNode) {
    756         var res = [];
     756        const res = [];
    757757        if (includeSelf && this._isMatch(selector)) {
    758758            res.push(this);
    759759        }
    760         var ancestor = this.parent;
     760        let ancestor = this.parent;
    761761        while (ancestor) {
    762762            if (ancestor === stopNode) {
     
    783783            return selector(this);
    784784        }
    785         var selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
     785        let selectorArr = selector.replace(/ /g, '').split(','), len = selectorArr.length, n, sel;
    786786        for (n = 0; n < len; n++) {
    787787            sel = selectorArr[n];
     
    810810    }
    811811    getLayer() {
    812         var parent = this.getParent();
     812        const parent = this.getParent();
    813813        return parent ? parent.getLayer() : null;
    814814    }
     
    817817    }
    818818    _getStage() {
    819         var parent = this.getParent();
     819        const parent = this.getParent();
    820820        if (parent) {
    821821            return parent.getStage();
     
    844844    }
    845845    _getAbsoluteTransform(top) {
    846         var at;
     846        let at;
    847847        if (top) {
    848848            at = new Util_1.Transform();
    849849            this._eachAncestorReverse(function (node) {
    850                 var transformsEnabled = node.transformsEnabled();
     850                const transformsEnabled = node.transformsEnabled();
    851851                if (transformsEnabled === 'all') {
    852852                    at.multiply(node.getTransform());
     
    866866                at.reset();
    867867            }
    868             var transformsEnabled = this.transformsEnabled();
     868            const transformsEnabled = this.transformsEnabled();
    869869            if (transformsEnabled === 'all') {
    870870                at.multiply(this.getTransform());
     
    882882    }
    883883    getAbsoluteScale(top) {
    884         var parent = this;
     884        let parent = this;
    885885        while (parent) {
    886886            if (parent._isUnderCache) {
     
    904904    _getTransform() {
    905905        var _a, _b;
    906         var m = this._cache.get(TRANSFORM) || new Util_1.Transform();
     906        const m = this._cache.get(TRANSFORM) || new Util_1.Transform();
    907907        m.reset();
    908         var x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
     908        const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
    909909        if (x !== 0 || y !== 0) {
    910910            m.translate(x, y);
     
    926926    }
    927927    clone(obj) {
    928         var attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
     928        let attrs = Util_1.Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
    929929        for (key in obj) {
    930930            attrs[key] = obj[key];
    931931        }
    932         var node = new this.constructor(attrs);
     932        const node = new this.constructor(attrs);
    933933        for (key in this.eventListeners) {
    934934            allListeners = this.eventListeners[key];
     
    948948    _toKonvaCanvas(config) {
    949949        config = config || {};
    950         var box = this.getClientRect();
    951         var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({
     950        const box = this.getClientRect();
     951        const stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({
    952952            width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
    953953            height: config.height ||
     
    977977    toDataURL(config) {
    978978        config = config || {};
    979         var mimeType = config.mimeType || null, quality = config.quality || null;
    980         var url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
     979        const mimeType = config.mimeType || null, quality = config.quality || null;
     980        const url = this._toKonvaCanvas(config).toDataURL(mimeType, quality);
    981981        if (config.callback) {
    982982            config.callback(url);
     
    10451045    }
    10461046    _off(type, name, callback) {
    1047         var evtListeners = this.eventListeners[type], i, evtName, handler;
     1047        let evtListeners = this.eventListeners[type], i, evtName, handler;
    10481048        for (i = 0; i < evtListeners.length; i++) {
    10491049            evtName = evtListeners[i].name;
     
    10691069    addName(name) {
    10701070        if (!this.hasName(name)) {
    1071             var oldName = this.name();
    1072             var newName = oldName ? oldName + ' ' + name : name;
     1071            const oldName = this.name();
     1072            const newName = oldName ? oldName + ' ' + name : name;
    10731073            this.name(newName);
    10741074        }
     
    10831083            return false;
    10841084        }
    1085         var names = (fullName || '').split(/\s/g);
     1085        const names = (fullName || '').split(/\s/g);
    10861086        return names.indexOf(name) !== -1;
    10871087    }
    10881088    removeName(name) {
    1089         var names = (this.name() || '').split(/\s/g);
    1090         var index = names.indexOf(name);
     1089        const names = (this.name() || '').split(/\s/g);
     1090        const index = names.indexOf(name);
    10911091        if (index !== -1) {
    10921092            names.splice(index, 1);
     
    10961096    }
    10971097    setAttr(attr, val) {
    1098         var func = this[SET + Util_1.Util._capitalize(attr)];
     1098        const func = this[SET + Util_1.Util._capitalize(attr)];
    10991099        if (Util_1.Util._isFunction(func)) {
    11001100            func.call(this, val);
     
    11121112    }
    11131113    _setAttr(key, val) {
    1114         var oldVal = this.attrs[key];
     1114        const oldVal = this.attrs[key];
    11151115        if (oldVal === val && !Util_1.Util.isObject(val)) {
    11161116            return;
     
    11281128    }
    11291129    _setComponentAttr(key, component, val) {
    1130         var oldVal;
     1130        let oldVal;
    11311131        if (val !== undefined) {
    11321132            oldVal = this.attrs[key];
     
    11421142            evt.target = this;
    11431143        }
    1144         var shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
     1144        const shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
    11451145            ((compareShape &&
    11461146                (this === compareShape ||
     
    11491149        if (!shouldStop) {
    11501150            this._fire(eventType, evt);
    1151             var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
     1151            const stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
    11521152                compareShape &&
    11531153                compareShape.isAncestorOf &&
     
    12071207    }
    12081208    _createDragElement(evt) {
    1209         var pointerId = evt ? evt.pointerId : undefined;
    1210         var stage = this.getStage();
    1211         var ap = this.getAbsolutePosition();
     1209        const pointerId = evt ? evt.pointerId : undefined;
     1210        const stage = this.getStage();
     1211        const ap = this.getAbsolutePosition();
    12121212        if (!stage) {
    12131213            return;
    12141214        }
    1215         var pos = stage._getPointerById(pointerId) ||
     1215        const pos = stage._getPointerById(pointerId) ||
    12161216            stage._changedPointerPositions[0] ||
    12171217            ap;
     
    12441244            return;
    12451245        }
    1246         var newNodePos = {
     1246        let newNodePos = {
    12471247            x: pos.x - elem.offset.x,
    12481248            y: pos.y - elem.offset.y,
    12491249        };
    1250         var dbf = this.dragBoundFunc();
     1250        const dbf = this.dragBoundFunc();
    12511251        if (dbf !== undefined) {
    12521252            const bounded = dbf.call(this, newNodePos, evt);
     
    12851285        this._dragCleanup();
    12861286        this.on('mousedown.konva touchstart.konva', function (evt) {
    1287             var shouldCheckButton = evt.evt['button'] !== undefined;
    1288             var canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;
     1287            const shouldCheckButton = evt.evt['button'] !== undefined;
     1288            const canDrag = !shouldCheckButton || Global_1.Konva.dragButtons.indexOf(evt.evt['button']) >= 0;
    12891289            if (!canDrag) {
    12901290                return;
     
    12931293                return;
    12941294            }
    1295             var hasDraggingChild = false;
     1295            let hasDraggingChild = false;
    12961296            DragAndDrop_1.DD._dragElements.forEach((elem) => {
    12971297                if (this.isAncestorOf(elem.node)) {
     
    13101310        else {
    13111311            this._dragCleanup();
    1312             var stage = this.getStage();
     1312            const stage = this.getStage();
    13131313            if (!stage) {
    13141314                return;
     
    13491349    }
    13501350    static _createNode(obj, container) {
    1351         var className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
     1351        let className = Node.prototype.getClassName.call(obj), children = obj.children, no, len, n;
    13521352        if (container) {
    13531353            obj.attrs.container = container;
Note: See TracChangeset for help on using the changeset viewer.