From f398fe482416d8237f04a83fe223d8aa0ff5f371 Mon Sep 17 00:00:00 2001 From: Sebastian Kupke Date: Thu, 9 Jan 2020 15:14:27 +0100 Subject: [PATCH] Fixed reference bug. --- dist/iwmlib.js | 38 ------ dist/iwmlib.pixi.js | 242 ++++++++++++++--------------------- lib/pixi/maps/geographics.js | 2 +- lib/pixi/maps/mapapp.js | 6 +- lib/pixi/maps/utils.js | 25 ++++ 5 files changed, 128 insertions(+), 185 deletions(-) diff --git a/dist/iwmlib.js b/dist/iwmlib.js index 7c23704..2da00b7 100644 --- a/dist/iwmlib.js +++ b/dist/iwmlib.js @@ -614,19 +614,6 @@ static toLine(event) { return `${event.type} #${event.target.id} ${event.clientX} ${event.clientY}` - let result = event.type; - let selector = this.selector(event.target); - result += ' selector: ' + selector; - if (event.target != document.querySelector(selector)) console.log('Cannot resolve', selector); - let keys = ['layerX', 'layerY', 'pageX', 'pageY', 'clientX', 'clientY']; - for (let key of keys) { - try { - result += ' ' + key + ':' + event[key]; - } catch (e) { - console.log('Invalid key: ' + key); - } - } - return result } static compareExtractedWithSimulated() { @@ -2646,25 +2633,6 @@ result[id] = this.getPosition(event); break } - // case 'TouchEvent': - // // Needs to be observed: Perhaps changedTouches are all we need. If so - // // we can remove the touchEventKey default parameter - // if (touchEventKey == 'all') { - // for(let t of event.targetTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // for(let t of event.changedTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // } - // else { - // for(let t of event.changedTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // } - // break - default: - break } return result } @@ -5759,8 +5727,6 @@ let bottom = parseFloat(this.element.style.bottom); this.element.style.bottom = bottom - delta.y + 'px'; break - default: - break } //console.log("onResize", this.onResize) if (this.onResize) { @@ -6183,8 +6149,6 @@ x = bbRight; if (!this.useEventPosWithBoundingBox) y = (bbTop + bbBottom) / 2; break - default: - break } } @@ -6240,8 +6204,6 @@ x += this.notchSize * 2; x += this.posOffset; break - default: - break } this.placeOrigin(x, y); } diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 2084911..9c78e77 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -1335,19 +1335,6 @@ static toLine(event) { return `${event.type} #${event.target.id} ${event.clientX} ${event.clientY}` - let result = event.type; - let selector = this.selector(event.target); - result += ' selector: ' + selector; - if (event.target != document.querySelector(selector)) console.log('Cannot resolve', selector); - let keys = ['layerX', 'layerY', 'pageX', 'pageY', 'clientX', 'clientY']; - for (let key of keys) { - try { - result += ' ' + key + ':' + event[key]; - } catch (e) { - console.log('Invalid key: ' + key); - } - } - return result } static compareExtractedWithSimulated() { @@ -6185,25 +6172,6 @@ result[id] = this.getPosition(event); break } - // case 'TouchEvent': - // // Needs to be observed: Perhaps changedTouches are all we need. If so - // // we can remove the touchEventKey default parameter - // if (touchEventKey == 'all') { - // for(let t of event.targetTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // for(let t of event.changedTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // } - // else { - // for(let t of event.changedTouches) { - // result[t.identifier.toString()] = this.getPosition(t) - // } - // } - // break - default: - break } return result } @@ -16823,6 +16791,31 @@ } } + class PIXIUtils { + /* + * Transform a pixi text to it's actual screensize, + * ignoring it's local transforms + */ + static toScreenFontSize(pixiText, fontSize = null) { + pixiText._recursivePostUpdateTransform(); + + let normalizedScale = { + x: pixiText.scale.x / pixiText.transform.worldTransform.a, + y: pixiText.scale.x / pixiText.transform.worldTransform.d + }; + + pixiText.scale = { x: normalizedScale.x, y: normalizedScale.y }; + if (fontSize) pixiText.style.fontSize = fontSize; + } + + static saveFill(graphics) { + return { + fill: graphics.fill.color, + alpha: graphics.fill.alpha + } + } + } + /** * The EventHandler class is used to take care of a event based design * pattern. Callbacks can subscribe to an event and these unknown sources @@ -17088,12 +17081,6 @@ * Specialization of the DisplayObjectScatter with special behavior needed for maps. */ class AdvancedScatter extends DisplayObjectScatter { - constructor() { - super(...arguments); - - this.onMoved = new EventHandler('onMove'); - } - /** * Animates the throw and ensures that the map is always visible. This * is different from the standard behavior. @@ -17111,7 +17098,6 @@ //when the object is not thrown. if (this.velocity != null) { - this.onMoved.call(this); let dt = this._throwDeltaTime(); // This seems to just correct the velocity when its calculated wrong. // In what case can it get bigger? Velocity tends to always shrink, when no force is added. @@ -18938,7 +18924,6 @@ */ windowPointToMapPoint(map, point) { let pointOnMap = { x: 0, y: 0 }; - if (map['image'] && map.image['parent']) { let offset = map.image.parent.toGlobal({ x: 0, y: 0 }); pointOnMap = new PIXI.Point( @@ -19266,31 +19251,6 @@ } } - class PIXIUtils { - /* - * Transform a pixi text to it's actual screensize, - * ignoring it's local transforms - */ - static toScreenFontSize(pixiText, fontSize = null) { - pixiText._recursivePostUpdateTransform(); - - let normalizedScale = { - x: pixiText.scale.x / pixiText.transform.worldTransform.a, - y: pixiText.scale.x / pixiText.transform.worldTransform.d - }; - - pixiText.scale = { x: normalizedScale.x, y: normalizedScale.y }; - if (fontSize) pixiText.style.fontSize = fontSize; - } - - static saveFill(graphics) { - return { - fill: graphics.fill.color, - alpha: graphics.fill.alpha - } - } - } - /** * * GeoGraphics are graphical objects, that does not store the graphics information * in screen space, but in geographical coordinates. Therefore GeoGraphics must be @@ -20672,9 +20632,9 @@ sceneFactory() { return new RigidScatterContainer(this.width, this.height, this.renderer, { app: this, - showBounds: true, - showTouches: true, - showPolygon: true, + showBounds: false, + showTouches: false, + showPolygon: false, container: this }) } @@ -21465,78 +21425,74 @@ * * It's highly configurable and adaptable to a variety of scenarios. * - * * @export * @class Overlay + * + * + * @param {object} options + * @param {object} options.name Name of the item. + * @param {object} options.borderColor + * @param {object} options.borderThickness + * @param {object} options.enabled Determines if enabled, disabled when false. + * @param {object} options.labelScale + * @param {object} options.location + * @param {object} options.label + * @param {object} options.labelType + * @param {object} options.labelLocation + * @param {object} options.labelAlignment + * @param {object} options.labelVerticalAlignment + * @param {object} options.labelSpacing + * @param {object} options.labelTarget + * @param {object} options.geometry + * @param {object} options.information + * @param {object} options.informationPath + * @param {object} options.informationType + * @param {object} options.icon + * @param {object} options.iconAlpha + * @param {object} options.iconAnchor + * @param {object} options.iconColor + * @param {object} options.iconScale + * @param {object} options.iconOffset + * @param {object} options.items + * @param {object} options.color Color of te point. + * @param {object} options.fillAlpha FillAlpha of the point. + * @param {object} options.size Size of the point. + * @param {object} options.scale Determines the scale of the graphics. + * @param {object} options.rescale Rescales the graphics relative to the map, that they keep their original scale. Only works for the entire overlay atm. Therefore must be set in the global param eters and not inside the children. + * @param {object} options.popoverOffset + * @param {object} options.zoomVisibility + * @param {object} options.labelMultiLineAlign + * @param {object} options.labelBreakWords + * @param {object} options.labelDropShadow + * @param {object} options.labelDropShadowAlpha + * @param {object} options.labelDropShadowAngle + * @param {object} options.labelDropShadowBlur + * @param {object} options.labelDropShadowColor + * @param {object} options.labelDropShadowDistance + * @param {object} options.fontColor + * @param {object} options.fontFamily + * @param {object} options.fontSize + * @param {object} options.fontStyle + * @param {object} options.fontWeight + * @param {object} options.labelStroke + * @param {object} options.labelStrokeThickness + * @param {object} options.wordWrap + * @param {object} options.wordWrapWidth + * @param {object} options.labelFill + * @param {object} options.labelFillGradientType + * @param {object} options.labelFillGradientStops + * @param {object} options.fontVariant + * @param {object} options.labelLeading + * @param {object} options.letterSpacing + * @param {object} options.labelLineHeight + * @param {object} options.labelLineJoin + * @param {object} options.labelMiterLimit + * @param {object} options.labelPadding + * @param {object} options.labelTrim + * @param {object} options.textBaseline + * @param {object} options.labelWhiteSpace */ class Overlay { - /** - * Creates an instance of Overlay. - * @param {*} [options={}] - * type - * @param{object} name - Name of the item. - * @param{object} borderColor - - * @param{object} borderThickness - - * @param{object} enabled - Determines if enabled, disabled when false. - * @param{object} labelScale - - * @param{object} location - - * @param{object} label - - * @param{object} labelType - - * @param{object} labelLocation - - * @param{object} labelAlignment - - * @param{object} labelVerticalAlignment - - * @param{object} labelSpacing - - * @param{object} labelTarget - - * @param{object} geometry - - * @param{object} information - - * @param{object} informationPath - - * @param{object} informationType - - * @param{object} icon - - * @param{object} iconAlpha - - * @param{object} iconAnchor - - * @param{object} iconColor - - * @param{object} iconScale - - * @param{object} iconOffset - - * @param{object} items - - * @param{object} color - Color of te point. - * @param{object} fillAlpha - FillAlpha of the point. - * @param{object} size - Size of the point. - * @param{object} scale - Determines the scale of the graphics. - * @param{object} rescale - Rescales the graphics relative to the map, that they keep their original scale. Only works for the entire overlay atm. Therefore must be set in the global parameters and not inside the children. - * @param{object} popoverOffset - - * @param{object} zoomVisibility - - * @param{object} labelMultiLineAlign - - * @param{object} labelBreakWords - - * @param{object} labelDropShadow - - * @param{object} labelDropShadowAlpha - - * @param{object} labelDropShadowAngle - - * @param{object} labelDropShadowBlur - - * @param{object} labelDropShadowColor - - * @param{object} labelDropShadowDistance - - * @param{object} fontColor - - * @param{object} fontFamily - - * @param{object} fontSize - - * @param{object} fontStyle - - * @param{object} fontWeight - - * @param{object} labelStroke - - * @param{object} labelStrokeThickness - - * @param{object} wordWrap - - * @param{object} wordWrapWidth - - * @param{object} labelFill - - * @param{object} labelFillGradientType - - * @param{object} labelFillGradientStops - - * @param{object} fontVariant - - * @param{object} labelLeading - - * @param{object} letterSpacing - - * @param{object} labelLineHeight - - * @param{object} labelLineJoin - - * @param{object} labelMiterLimit - - * @param{object} labelPadding - - * @param{object} labelTrim - - * @param{object} textBaseline - - * @param{object} labelWhiteSpace - - * @memberof Overlay - */ constructor(options = {}) { let defaultTextStyle = new PIXI.TextStyle(); @@ -21638,7 +21594,7 @@ * while conserving already set disabled properties. * * @param {*} options - * @returns + * @returns {object} - Returns the modified options object. * @memberof Overlay */ addDisabled(options) { @@ -21787,7 +21743,7 @@ * @param {*} item * @param {*} property * @param {boolean} [enabled=true] - * @returns + * @returns {any} - Returns the picked item property. * @memberof Overlay */ pickItemProperty(item, property, enabled = true) { @@ -21804,7 +21760,7 @@ * * @param {*} item * @param {*} property - * @returns + * @returns {any} - Returns the picked item property. * @memberof Overlay */ getDisabledItemProperty(item, property) { @@ -21822,7 +21778,7 @@ * * @param {OverlayItem} item - Item to get the informations from. * @param {string} property - Name of the property. - * @returns {any} + * @returns {any} - Returns the picked item property. * @memberof Overlay */ getItemProperty(item, property) { @@ -21856,7 +21812,7 @@ * * @param {*} item * @param {*} property - * @returns + * @returns {any} - Returns the reference as object or the property. * @memberof Overlay */ _resolveReference(item, property) { @@ -21918,7 +21874,7 @@ * * @param {*} item * @param {*} [informationCallback=null] - * @returns + * @returns {GeoGraphics} - Returns the created geographics. * @memberof Overlay */ createItem(item, informationCallback = null) { @@ -21976,7 +21932,7 @@ * Draws a label that is shown next to the item on the map. * * @param {*} item - * @returns + * @returns {PIXI.Text} - Returns the created label or null. * @memberof Overlay */ _createLabel(item) { diff --git a/lib/pixi/maps/geographics.js b/lib/pixi/maps/geographics.js index 3c5be8b..02a3c59 100644 --- a/lib/pixi/maps/geographics.js +++ b/lib/pixi/maps/geographics.js @@ -2,7 +2,7 @@ import { Points } from '../../utils.js' import { EventHandler } from './utils.js' import { FlagPolygon } from '../graphics/label.js' import { DeepZoomMap } from './map.js' -import { PIXIUtils } from '../../../../js/pixi/utils.js' +import { PIXIUtils } from './utils.js' /** * * GeoGraphics are graphical objects, that does not store the graphics information diff --git a/lib/pixi/maps/mapapp.js b/lib/pixi/maps/mapapp.js index ae61e7f..d9f9dfa 100644 --- a/lib/pixi/maps/mapapp.js +++ b/lib/pixi/maps/mapapp.js @@ -225,9 +225,9 @@ export default class MapApp extends PIXIApp { sceneFactory() { return new RigidScatterContainer(this.width, this.height, this.renderer, { app: this, - showBounds: true, - showTouches: true, - showPolygon: true, + showBounds: false, + showTouches: false, + showPolygon: false, container: this }) } diff --git a/lib/pixi/maps/utils.js b/lib/pixi/maps/utils.js index 6b9fb06..d48654d 100644 --- a/lib/pixi/maps/utils.js +++ b/lib/pixi/maps/utils.js @@ -258,6 +258,31 @@ export class Vector { } } +export class PIXIUtils { + /* + * Transform a pixi text to it's actual screensize, + * ignoring it's local transforms + */ + static toScreenFontSize(pixiText, fontSize = null) { + pixiText._recursivePostUpdateTransform(); + + let normalizedScale = { + x: pixiText.scale.x / pixiText.transform.worldTransform.a, + y: pixiText.scale.x / pixiText.transform.worldTransform.d + }; + + pixiText.scale = { x: normalizedScale.x, y: normalizedScale.y }; + if (fontSize) pixiText.style.fontSize = fontSize; + } + + static saveFill(graphics) { + return { + fill: graphics.fill.color, + alpha: graphics.fill.alpha + } + } +} + /** * The EventHandler class is used to take care of a event based design * pattern. Callbacks can subscribe to an event and these unknown sources