Fixed reference bug.

This commit is contained in:
Sebastian Kupke 2020-01-09 15:14:27 +01:00
parent d5b87f23cf
commit f398fe4824
5 changed files with 128 additions and 185 deletions

38
dist/iwmlib.js vendored
View File

@ -614,19 +614,6 @@
static toLine(event) { static toLine(event) {
return `${event.type} #${event.target.id} ${event.clientX} ${event.clientY}` 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() { static compareExtractedWithSimulated() {
@ -2646,25 +2633,6 @@
result[id] = this.getPosition(event); result[id] = this.getPosition(event);
break 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 return result
} }
@ -5759,8 +5727,6 @@
let bottom = parseFloat(this.element.style.bottom); let bottom = parseFloat(this.element.style.bottom);
this.element.style.bottom = bottom - delta.y + 'px'; this.element.style.bottom = bottom - delta.y + 'px';
break break
default:
break
} }
//console.log("onResize", this.onResize) //console.log("onResize", this.onResize)
if (this.onResize) { if (this.onResize) {
@ -6183,8 +6149,6 @@
x = bbRight; x = bbRight;
if (!this.useEventPosWithBoundingBox) y = (bbTop + bbBottom) / 2; if (!this.useEventPosWithBoundingBox) y = (bbTop + bbBottom) / 2;
break break
default:
break
} }
} }
@ -6240,8 +6204,6 @@
x += this.notchSize * 2; x += this.notchSize * 2;
x += this.posOffset; x += this.posOffset;
break break
default:
break
} }
this.placeOrigin(x, y); this.placeOrigin(x, y);
} }

242
dist/iwmlib.pixi.js vendored
View File

@ -1335,19 +1335,6 @@
static toLine(event) { static toLine(event) {
return `${event.type} #${event.target.id} ${event.clientX} ${event.clientY}` 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() { static compareExtractedWithSimulated() {
@ -6185,25 +6172,6 @@
result[id] = this.getPosition(event); result[id] = this.getPosition(event);
break 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 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 * The EventHandler class is used to take care of a event based design
* pattern. Callbacks can subscribe to an event and these unknown sources * 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. * Specialization of the DisplayObjectScatter with special behavior needed for maps.
*/ */
class AdvancedScatter extends DisplayObjectScatter { class AdvancedScatter extends DisplayObjectScatter {
constructor() {
super(...arguments);
this.onMoved = new EventHandler('onMove');
}
/** /**
* Animates the throw and ensures that the map is always visible. This * Animates the throw and ensures that the map is always visible. This
* is different from the standard behavior. * is different from the standard behavior.
@ -17111,7 +17098,6 @@
//when the object is not thrown. //when the object is not thrown.
if (this.velocity != null) { if (this.velocity != null) {
this.onMoved.call(this);
let dt = this._throwDeltaTime(); let dt = this._throwDeltaTime();
// This seems to just correct the velocity when its calculated wrong. // 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. // In what case can it get bigger? Velocity tends to always shrink, when no force is added.
@ -18938,7 +18924,6 @@
*/ */
windowPointToMapPoint(map, point) { windowPointToMapPoint(map, point) {
let pointOnMap = { x: 0, y: 0 }; let pointOnMap = { x: 0, y: 0 };
if (map['image'] && map.image['parent']) { if (map['image'] && map.image['parent']) {
let offset = map.image.parent.toGlobal({ x: 0, y: 0 }); let offset = map.image.parent.toGlobal({ x: 0, y: 0 });
pointOnMap = new PIXI.Point( 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 * * GeoGraphics are graphical objects, that does not store the graphics information
* in screen space, but in geographical coordinates. Therefore GeoGraphics must be * in screen space, but in geographical coordinates. Therefore GeoGraphics must be
@ -20672,9 +20632,9 @@
sceneFactory() { sceneFactory() {
return new RigidScatterContainer(this.width, this.height, this.renderer, { return new RigidScatterContainer(this.width, this.height, this.renderer, {
app: this, app: this,
showBounds: true, showBounds: false,
showTouches: true, showTouches: false,
showPolygon: true, showPolygon: false,
container: this container: this
}) })
} }
@ -21465,78 +21425,74 @@
* *
* It's highly configurable and adaptable to a variety of scenarios. * It's highly configurable and adaptable to a variety of scenarios.
* *
*
* @export * @export
* @class Overlay * @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 { 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 = {}) { constructor(options = {}) {
let defaultTextStyle = new PIXI.TextStyle(); let defaultTextStyle = new PIXI.TextStyle();
@ -21638,7 +21594,7 @@
* while conserving already set disabled properties. * while conserving already set disabled properties.
* *
* @param {*} options * @param {*} options
* @returns * @returns {object} - Returns the modified options object.
* @memberof Overlay * @memberof Overlay
*/ */
addDisabled(options) { addDisabled(options) {
@ -21787,7 +21743,7 @@
* @param {*} item * @param {*} item
* @param {*} property * @param {*} property
* @param {boolean} [enabled=true] * @param {boolean} [enabled=true]
* @returns * @returns {any} - Returns the picked item property.
* @memberof Overlay * @memberof Overlay
*/ */
pickItemProperty(item, property, enabled = true) { pickItemProperty(item, property, enabled = true) {
@ -21804,7 +21760,7 @@
* *
* @param {*} item * @param {*} item
* @param {*} property * @param {*} property
* @returns * @returns {any} - Returns the picked item property.
* @memberof Overlay * @memberof Overlay
*/ */
getDisabledItemProperty(item, property) { getDisabledItemProperty(item, property) {
@ -21822,7 +21778,7 @@
* *
* @param {OverlayItem} item - Item to get the informations from. * @param {OverlayItem} item - Item to get the informations from.
* @param {string} property - Name of the property. * @param {string} property - Name of the property.
* @returns {any} * @returns {any} - Returns the picked item property.
* @memberof Overlay * @memberof Overlay
*/ */
getItemProperty(item, property) { getItemProperty(item, property) {
@ -21856,7 +21812,7 @@
* *
* @param {*} item * @param {*} item
* @param {*} property * @param {*} property
* @returns * @returns {any} - Returns the reference as object or the property.
* @memberof Overlay * @memberof Overlay
*/ */
_resolveReference(item, property) { _resolveReference(item, property) {
@ -21918,7 +21874,7 @@
* *
* @param {*} item * @param {*} item
* @param {*} [informationCallback=null] * @param {*} [informationCallback=null]
* @returns * @returns {GeoGraphics} - Returns the created geographics.
* @memberof Overlay * @memberof Overlay
*/ */
createItem(item, informationCallback = null) { createItem(item, informationCallback = null) {
@ -21976,7 +21932,7 @@
* Draws a label that is shown next to the item on the map. * Draws a label that is shown next to the item on the map.
* *
* @param {*} item * @param {*} item
* @returns * @returns {PIXI.Text} - Returns the created label or null.
* @memberof Overlay * @memberof Overlay
*/ */
_createLabel(item) { _createLabel(item) {

View File

@ -2,7 +2,7 @@ import { Points } from '../../utils.js'
import { EventHandler } from './utils.js' import { EventHandler } from './utils.js'
import { FlagPolygon } from '../graphics/label.js' import { FlagPolygon } from '../graphics/label.js'
import { DeepZoomMap } from './map.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 * * GeoGraphics are graphical objects, that does not store the graphics information

View File

@ -225,9 +225,9 @@ export default class MapApp extends PIXIApp {
sceneFactory() { sceneFactory() {
return new RigidScatterContainer(this.width, this.height, this.renderer, { return new RigidScatterContainer(this.width, this.height, this.renderer, {
app: this, app: this,
showBounds: true, showBounds: false,
showTouches: true, showTouches: false,
showPolygon: true, showPolygon: false,
container: this container: this
}) })
} }

View File

@ -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 * The EventHandler class is used to take care of a event based design
* pattern. Callbacks can subscribe to an event and these unknown sources * pattern. Callbacks can subscribe to an event and these unknown sources