Improved wrapper event handling.

This commit is contained in:
2019-07-24 11:45:03 +02:00
parent cc6ef8de46
commit ed40ffc43f
4 changed files with 46 additions and 18 deletions
+17 -9
View File
@@ -10097,14 +10097,14 @@
}
if (this.tapNodes.has(node)) {
handler = this.tapNodes.get(node);
handler(event);
handler(event, node);
return true
}
for (let [selector, handler] of this.tapHandler.entries()) {
console.log("nodeTapped", selector);
for (let obj of this.domNode.querySelectorAll(selector)) {
if (node == obj) {
handler(event);
handler(event, node);
return true
}
}
@@ -10351,22 +10351,21 @@
} else console.log('Element was no parent:', target);
}
this._bringToFront(target);
let svgRoot = target.closest('svg');
if (svgRoot == null) {
return
}
let image = svgRoot.querySelector('image');
// eslint-disable-next-line no-unused-vars
let [mask, maskImage] = Highlight$1._getSVGMask(target, {
svgRoot,
image
});
let center = Highlight$1._calculateCenterRelativeTo(target, image);
console.log("_calculateCenterRelativeTo", center);
TweenLite.set(maskImage, {
transformOrigin: `${center.x}% ${center.y}%`
transformOrigin: `${center.x} ${center.y}`
});
TweenLite.set(target, { transformOrigin: '50% 50%' });
@@ -10380,6 +10379,7 @@
}
static toggleHighlight(node) {
console.log("toggleHighlight", Highlight$1._isExpanded(node));
if (Highlight$1._isExpanded(node)) {
Highlight$1.closeHighlight(node);
} else {
@@ -10483,6 +10483,12 @@
svgGroup.insertBefore(maskImage, element); // image.nextSibling)
TweenLite.set(maskImage, { scale: 1 });
maskImage.style.mask = 'url(#' + maskId + ')';
let rect = document.createElementNS(svg, 'rect');
rect.setAttribute('width', width);
rect.setAttribute('height', height);
rect.classList.add('debugRect');
svgGroup.appendChild(rect);
}
svgGroup.appendChild(maskImage);
@@ -10497,7 +10503,9 @@
let height = bbox.height;
let cx = target.getAttribute('cx');
let cy = target.getAttribute('cy');
return { x: (cx / width) * 100, y: (cy / height) * 100 }
let x = cx.endsWith('%') ? cx : round((cx / width) * 100) + '%';
let y = cy.endsWith('%') ? cy : round((cy / height) * 100) + '%';
return { x, y }
}
static _isExpanded(target) {
@@ -10513,12 +10521,12 @@
}
static closeHighlight(target, { animation = 0.5 } = {}) {
console.log('Close Highlight');
Highlight$1._notExpanded(target);
// eslint-disable-next-line no-unused-vars
let [mask, maskImage] = Highlight$1._getSVGMask(target);
console.log('Close Highlight', maskImage);
TweenLite.to([target, maskImage], animation, {
scale: 1
});