File tree 6 files changed +31
-0
lines changed
6 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 128
128
],
129
129
130
130
"Widgets" : [
131
+ " Widget" ,
131
132
" Navigation" ,
132
133
" Minimap" ,
133
134
" Scale" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const DEFAULT_OPTIONS = {
18
18
/**
19
19
* A widget for minimap
20
20
*
21
+ * @extends Widget
22
+ *
21
23
* @property {HTMLElement } domElement An html div containing the minimap.
22
24
* @property {HTMLElement } parentElement The parent HTML container of `this.domElement`.
23
25
*/
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ const DEFAULT_OPTIONS = {
16
16
/**
17
17
* A widget menu manager for navigation.
18
18
*
19
+ * @extends Widget
20
+ *
19
21
* @property {HTMLElement } domElement An html div containing all navigation widgets.
20
22
* @property {HTMLElement } parentElement The parent HTML container of `this.domElement`.
21
23
* @property {Object } onClick An object containing methods which are executed when clicking one of the
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ const DEFAULT_OPTIONS = {
15
15
/**
16
16
* A widget for scale
17
17
*
18
+ * @extends Widget
19
+ *
18
20
* @property {HTMLElement } domElement An html div containing the scale.
19
21
* @property {HTMLElement } parentElement The parent HTML container of `this.domElement`.
20
22
*/
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ function eraseSuggestionList(form) {
45
45
/**
46
46
* A widget for searchbar
47
47
*
48
+ * @extends Widget
49
+ *
48
50
* @property {HTMLElement } domElement An html div containing the searchbar.
49
51
* @property {HTMLElement } parentElement The parent HTML container of `this.domElement`.
50
52
*/
Original file line number Diff line number Diff line change
1
+ /**
2
+ * An interface that stores common methods for all specific widgets.
3
+ *
4
+ * @hideconstructor
5
+ */
1
6
class Widget {
7
+ #_display;
8
+
2
9
constructor ( view , options = { } , defaultOptions ) {
3
10
this . parentElement = options . parentElement || view . domElement ;
4
11
@@ -58,6 +65,21 @@ class Widget {
58
65
this . domElement . addEventListener ( 'pointerdown' , ( e ) => { e . stopPropagation ( ) ; } ) ;
59
66
this . domElement . addEventListener ( 'mousedown' , ( e ) => { e . stopPropagation ( ) ; } ) ;
60
67
}
68
+
69
+ /**
70
+ * Change the widget style `display` property so that the widget becomes visible.
71
+ */
72
+ show ( ) {
73
+ this . domElement . style . display = this . #_display;
74
+ }
75
+
76
+ /**
77
+ * Change the widget style `display` property so that the widget becomes invisible.
78
+ */
79
+ hide ( ) {
80
+ this . #_display = window . getComputedStyle ( this . domElement ) . display ;
81
+ this . domElement . style . display = 'none' ;
82
+ }
61
83
}
62
84
63
85
You can’t perform that action at this time.
0 commit comments