- npm updates for dev tools

- three.js update to 0.124.0
- EventEmitter.js: emit args array
- RangeSlider.js and RangeSlider.css: schow also the ticks
This commit is contained in:
Arno Kaimbacher 2021-01-07 15:45:32 +01:00
parent ca1a983665
commit e62d4908f0
8 changed files with 717 additions and 793 deletions

1341
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"proj4": "^2.6.3", "proj4": "^2.6.3",
"three": "^0.123.0" "three": "^0.124.0"
}, },
"author": "Arno Kaimbacher", "author": "Arno Kaimbacher",
"license": "MIT", "license": "MIT",

View File

@ -53,7 +53,8 @@ export class Coordinates extends Control {
map.removeListener('mouse-move', this._onMouseMove, this); map.removeListener('mouse-move', this._onMouseMove, this);
} }
_onMouseMove(event) { _onMouseMove(e) {
let event = e[0];
let canvasOffset = this._getOffset(this.map.domElement); let canvasOffset = this._getOffset(this.map.domElement);
let xClickedOnCanvas = event.clientX - canvasOffset.left; let xClickedOnCanvas = event.clientX - canvasOffset.left;
let yClickedonCanvas = event.clientY - canvasOffset.top; let yClickedonCanvas = event.clientY - canvasOffset.top;

View File

@ -1,9 +1,9 @@
.gba-control-slider { /* .gba-control-slider {
background: none repeat scroll 0 0 #FFF; background: none repeat scroll 0 0 #FFF;
} } */
.gba-control-slider.vertical { .gba-control-slider.vertical {
width: 26px; /* width: 26px; */
height: 100%; height: 100%;
/* background-color: azure; */ /* background-color: azure; */
} }

View File

@ -131,7 +131,7 @@ export class SliderControl extends Control {
} }
_updateValue(e) { _updateValue(e) {
this.value = e.value;//this.slider.value; this.value = e[0];//this.slider.value;
if (this.options.showValue) { if (this.options.showValue) {
this._sliderValue.innerHTML = this.value; this._sliderValue.innerHTML = this.value;
} }
@ -146,7 +146,7 @@ export class SliderControl extends Control {
//},this); //},this);
for (var prop in this._map._layers) { for (var prop in this._map._layers) {
if (this._map._layers.hasOwnProperty(prop)) { if (this._map._layers.hasOwnProperty(prop)) {
var layer = this._map._layers[prop]; let layer = this._map._layers[prop];
// if (layer.declaredClass === "GridLayer" || layer.declaredClass === "DxfLayer" || layer.declaredClass === "DemLayer") // if (layer.declaredClass === "GridLayer" || layer.declaredClass === "DxfLayer" || layer.declaredClass === "DemLayer")
layer.scaleZ(this.value); layer.scaleZ(this.value);
} }

View File

@ -3,7 +3,10 @@ import * as util from './utilities';
var eventsKey = '_events'; var eventsKey = '_events';
class EventEmitter { class EventEmitter {
// events = {};
constructor() { constructor() {
this.events = {};
} }
_getEvents() { _getEvents() {
@ -93,6 +96,10 @@ class EventEmitter {
return this; return this;
} }
on(eventName, fn, context) {
return this.addListener(eventName, fn, context);
}
removeListener(evt, fn, context) { // ([String, Function, Object]) or (Object[, Object]) removeListener(evt, fn, context) { // ([String, Function, Object]) or (Object[, Object])
if (!this[eventsKey]) { if (!this[eventsKey]) {
@ -147,6 +154,10 @@ class EventEmitter {
return this; return this;
} }
off(eventName, fn, context) {
return this.removeListener(eventName, fn, context);
}
hasEventListeners(type) { // (String) -> Boolean hasEventListeners(type) { // (String) -> Boolean
var events = this[eventsKey]; var events = this[eventsKey];
return !!events && ((type in events && events[type].length > 0) || return !!events && ((type in events && events[type].length > 0) ||
@ -154,12 +165,14 @@ class EventEmitter {
} }
// (String[, Object]) // (String[, Object])
emit(type, data) { // emit(type, data) {
emit(type, ...args) {
if (!this.hasEventListeners(type)) { if (!this.hasEventListeners(type)) {
return this; return this;
} }
let event = util.extend({}, data, { type: type, target: this }); // let event = util.extend({}, data, { type: type, target: this });
let event = util.extend({}, args, { type: type, target: this });
let events = this[eventsKey], let events = this[eventsKey],
listeners, i, len, typeIndex, contextId; listeners, i, len, typeIndex, contextId;
@ -169,7 +182,11 @@ class EventEmitter {
listeners = events[type].slice(); listeners = events[type].slice();
for (i = 0, len = listeners.length; i < len; i++) { for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context, event); // listeners[i].action.call(listeners[i].context, event);
let listener = listeners[i];
listener.action.call(listener.context, event);
// listener.apply(this, args);
} }
} }
@ -181,7 +198,9 @@ class EventEmitter {
if (listeners) { if (listeners) {
for (i = 0, len = listeners.length; i < len; i++) { for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context, event); // listeners[i].action.call(listeners[i].context, event);
let listener = listeners[i];
listener.action.call(listener.context, event);
} }
} }
} }

View File

@ -1,23 +1,13 @@
/* .range-slider-track .dragger {
display: block;
position: relative;
z-index: 2;
cursor: inherit;
border: none;
height: inherit;
width: 14px;
border-radius: 5%;
background: #333;
} */
.slider { .slider {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
position: relative; position: relative;
overflow: visible;
} }
.slider.slider-vertical { .slider.slider-vertical {
height: 160px; height: 160px;
width: 25px; width: 30px;
} }
.slider.slider-vertical .range-slider-track { .slider.slider-vertical .range-slider-track {
@ -25,16 +15,17 @@
/* cursor: pointer; */ /* cursor: pointer; */
width: 5px; width: 5px;
height: 100%; height: 100%;
/* margin-left: -5px; */ margin-left: -2.5px;
left: 50%; left: 50%;
top: 0; top: 0;
} }
.slider.slider-vertical .slider-selection { .slider.slider-vertical .slider-selection {
width: 100%; width: 100%;
left: 0; left: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
border-radius:0%; /* border-radius:0%; */
} }
/* .slider-vertical .range-slider-track:before { /* .slider-vertical .range-slider-track:before {
@ -46,9 +37,10 @@
} */ } */
.slider.slider-vertical .slider-handle { .slider.slider-vertical .slider-handle {
margin-left: -10px; margin-left: -7.5px;
/* margin-top: -10px; */ margin-top: -4px;
} }
.slider.slider-vertical .slider-handle.triangle { .slider.slider-vertical .slider-handle.triangle {
border-width: 10px 0 10px 10px; border-width: 10px 0 10px 10px;
width: 1px; width: 1px;
@ -57,7 +49,20 @@
margin-left: 0; margin-left: 0;
} }
.slider-ticks {
overflow: visible;
}
.slider-tick {
position: absolute;
width: 100%;
min-height: 2px;
/* margin-left: 20px; */
/* padding-top: 2.5px; */
background-color: #6b716f;
overflow: visible;
margin-top: -2px;
}
/*.no-select { /*.no-select {
-webkit-touch-callout: none; -webkit-touch-callout: none;
@ -86,7 +91,6 @@
left: 0; left: 0;
} }
.slider.slider-horizontal .slider-selection { .slider.slider-horizontal .slider-selection {
height: 100%; height: 100%;
top: 0; top: 0;
@ -98,17 +102,15 @@
margin-top: -5px; margin-top: -5px;
} }
.range-slider-track { .range-slider-track {
position: absolute; position: absolute;
cursor: pointer; cursor: pointer;
background-color: #333; /* background-color: #333; */
background-color: #6b716f;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
border-radius: 4px; border-radius: 4px;
} }
/*.slider.slider-horizontal .slider-handle.triangle { /*.slider.slider-horizontal .slider-handle.triangle {
border-width: 0 10px 10px 10px; border-width: 0 10px 10px 10px;
width: 0; width: 0;
@ -117,10 +119,10 @@
margin-top: 0; margin-top: 0;
}*/ }*/
.slider input { .slider input {
display: none; display: none;
} }
.slider .tooltip-inner { .slider .tooltip-inner {
white-space: nowrap; white-space: nowrap;
} }
@ -143,7 +145,7 @@
.slider-handle { .slider-handle {
position: absolute; position: absolute;
width: 25px; width: 20px;
height: 10px; height: 10px;
/* background-color: #0e90d2; */ /* background-color: #0e90d2; */
background-color: black; background-color: black;
@ -157,10 +159,7 @@
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .05);
opacity: 0.8; opacity: 0.8;
border: 0 solid transparent; border: 0 solid transparent;
} z-index: 999;
.slider-handle.round {
/* border-radius: 20px; */
} }
.slider-handle.triangle { .slider-handle.triangle {

View File

@ -16,12 +16,10 @@ class RangeSlider extends EventEmitter {
orientation: "horizontal", orientation: "horizontal",
rangeClass: "", // add extra custom class for the range slider track rangeClass: "", // add extra custom class for the range slider track
draggerClass: "",// add extra custom class for the range slider dragger draggerClass: "",// add extra custom class for the range slider dragger
//min: -50,
//max: 50,
selection: 'before', selection: 'before',
tooltip: 'show', tooltip: 'show',
handle: 'round', handle: 'round',
step: 1 stepSize: 1
}; };
constructor(elem, options) { constructor(elem, options) {
@ -40,6 +38,7 @@ class RangeSlider extends EventEmitter {
'<div class="slider-handle"></div>' + '<div class="slider-handle"></div>' +
'<div class="slider-handle"></div>' + '<div class="slider-handle"></div>' +
'</div>' + '</div>' +
'<div class="slider-ticks"></div>' +
'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
}, this.element); }, this.element);
@ -49,6 +48,8 @@ class RangeSlider extends EventEmitter {
this.tooltip = this.picker.getElementsByClassName('tooltip')[0]; this.tooltip = this.picker.getElementsByClassName('tooltip')[0];
this.tooltipInner = this.tooltip.getElementsByClassName('tooltip-inner')[0]; this.tooltipInner = this.tooltip.getElementsByClassName('tooltip-inner')[0];
this.sliderTrack = this.picker.getElementsByClassName('range-slider-track')[0]; this.sliderTrack = this.picker.getElementsByClassName('range-slider-track')[0];
this.sliderTicks = this.picker.getElementsByClassName('slider-ticks')[0];
this.orientation = this.options.orientation; this.orientation = this.options.orientation;
@ -77,12 +78,22 @@ class RangeSlider extends EventEmitter {
this.min = this.options.min; this.min = this.options.min;
this.max = this.options.max; this.max = this.options.max;
this.step = this.options.step; this.stepSize = this.options.stepSize;
this.value = this.options.value; this.value = this.options.value;
//if (this.value[1]) { //if (this.value[1]) {
// this.range = true; // this.range = true;
//} //}
let positionStep = 160/4;
let topPosition = 0;
for (let i = this.min; i <= this.max; i = i + this.stepSize) {
let sliderTick = dom.createDom("div", {
"class": 'slider-tick'
}, this.sliderTicks);
sliderTick.style.top = topPosition + 'px';
topPosition = topPosition + positionStep;
}
this.selection = this.options.selection; this.selection = this.options.selection;
this.selectionEl = this.picker.getElementsByClassName('slider-selection')[0]; this.selectionEl = this.picker.getElementsByClassName('slider-selection')[0];
if (this.selection === 'none') { if (this.selection === 'none') {
@ -127,7 +138,7 @@ class RangeSlider extends EventEmitter {
this.percentage = [ this.percentage = [
(this.value[0] - this.min) * 100 / this.diff, (this.value[0] - this.min) * 100 / this.diff,
(this.value[1] - this.min) * 100 / this.diff, (this.value[1] - this.min) * 100 / this.diff,
this.step * 100 / this.diff this.stepSize * 100 / this.diff
]; ];
//this.offset = this.picker.offset(); //this.offset = this.picker.offset();
@ -209,8 +220,8 @@ class RangeSlider extends EventEmitter {
this.dragged = 0; this.dragged = 0;
} }
this.percentage[this.dragged] = percentage; // this.percentage[this.dragged] = percentage;
this.layout(); // this.layout();
domEvent.on(this.picker, "mousemove", this.mousemove, this); domEvent.on(this.picker, "mousemove", this.mousemove, this);
domEvent.on(this.picker, 'mouseup', this.mouseup, this); domEvent.on(this.picker, 'mouseup', this.mouseup, this);
@ -221,8 +232,15 @@ class RangeSlider extends EventEmitter {
//if (this.options.inverse === true) { //if (this.options.inverse === true) {
// val = val * -1; // val = val * -1;
//} //}
// this.emit("slide", { value: value });
this.emit("slide", { value: value }); // this.percentage[this.dragged] = percentage;
if (this.percentage[this.dragged] != percentage) {
this.percentage[this.dragged] = percentage;
this.layout();
let value = this.calculateValue();
this.emit("slide", value);
}
return false; return false;
} }
@ -252,7 +270,7 @@ class RangeSlider extends EventEmitter {
this.percentage[this.dragged] = percentage; this.percentage[this.dragged] = percentage;
this.layout(); this.layout();
let value = this.calculateValue(); let value = this.calculateValue();
this.emit("slide", { value: value }); this.emit("slide", value);
} }
//if (this.options.inverse === true) { //if (this.options.inverse === true) {
// val = val * -1; // val = val * -1;
@ -301,12 +319,12 @@ class RangeSlider extends EventEmitter {
var val; var val;
if (this.range) { if (this.range) {
val = [ val = [
(this.min + Math.round((this.diff * this.percentage[0] / 100) / this.step) * this.step), (this.min + Math.round((this.diff * this.percentage[0] / 100) / this.stepSize) * this.stepSize),
(this.min + Math.round((this.diff * this.percentage[1] / 100) / this.step) * this.step) (this.min + Math.round((this.diff * this.percentage[1] / 100) / this.stepSize) * this.stepSize)
]; ];
this.value = val; this.value = val;
} else { } else {
val = (this.min + Math.round((this.diff * this.percentage[0] / 100) / this.step) * this.step); val = (this.min + Math.round((this.diff * this.percentage[0] / 100) / this.stepSize) * this.stepSize);
this.value = [val, this.value[1]]; this.value = [val, this.value[1]];
} }
return val; return val;
@ -316,7 +334,7 @@ class RangeSlider extends EventEmitter {
if (this.touchCapable) { if (this.touchCapable) {
ev = ev.touches[0]; ev = ev.touches[0];
} }
var percentage = (ev[this.mousePos] - this.offset[this.stylePos]) * 100 / this.size; let percentage = (ev[this.mousePos] - this.offset[this.stylePos]) * 100 / this.size;
percentage = Math.round(percentage / this.percentage[2]) * this.percentage[2]; percentage = Math.round(percentage / this.percentage[2]) * this.percentage[2];
return Math.max(0, Math.min(100, percentage)); return Math.max(0, Math.min(100, percentage));
} }
@ -347,7 +365,7 @@ class RangeSlider extends EventEmitter {
this.percentage = [ this.percentage = [
(this.value[0] - this.min) * 100 / this.diff, (this.value[0] - this.min) * 100 / this.diff,
(this.value[1] - this.min) * 100 / this.diff, (this.value[1] - this.min) * 100 / this.diff,
this.step * 100 / this.diff this.stepSize * 100 / this.diff
]; ];
this.layout(); this.layout();
} }