Skip to content

Commit 0c833bf

Browse files
committed
Add CSS for 'more results'
1 parent 1719592 commit 0c833bf

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/mapml.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,6 @@ label.mapml-layer-item-toggle {
798798
max-height: 100%;
799799
max-width: 100%;
800800
border-radius: 4px;
801-
padding: 5px 10px;
802801
background-color: #fff;
803802
cursor: default;
804803
z-index: 1000;
@@ -814,9 +813,18 @@ label.mapml-layer-item-toggle {
814813
font: inherit;
815814
}
816815

816+
.mapml-feature-index-more-content {
817+
display: inline-block;
818+
}
819+
.mapml-feature-index-more-content > span{
820+
padding: 5px 10px 5px 0;
821+
display: inline-block;
822+
}
817823
.mapml-feature-index-content {
824+
padding: 5px 10px;
818825
display: inline-block;
819826
}
827+
.mapml-feature-index-more-content > span > span,
820828
.mapml-feature-index-content > span{
821829
display: block;
822830
font-family: monospace;

src/mapml/layers/FeatureIndex.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export var FeatureIndex = L.Layer.extend({
1919

2020
this._output = L.DomUtil.create("output", "mapml-feature-index", map._container);
2121
this._body = L.DomUtil.create("span", "mapml-feature-index-content", this._output);
22-
this._moreContent = L.DomUtil.create("span", "mapml-feature-index-content more-content", this._output);
22+
this._moreContent = L.DomUtil.create("span", "mapml-feature-index-more-content", this._output);
2323
this._moreContent.style.display = "none";
2424

2525
map.on("layerchange layeradd layerremove overlayremove", this._toggleEvents, this);
@@ -54,13 +54,21 @@ export var FeatureIndex = L.Layer.extend({
5454
keys.forEach(i => {
5555
if(layers[i].featureAttributes && featureIndexBounds.overlaps(layers[i]._bounds)){
5656
let label = layers[i].group.getAttribute("aria-label");
57-
if(index === 9){
58-
body.appendChild(this._updateOutput("More results", 9));
59-
index += 1;
57+
58+
if(index%9 === 0){
59+
let span = document.createElement("span");
60+
span.setAttribute("id", index/9);
61+
moreContent.appendChild(span);
62+
if(index === 9){
63+
body.appendChild(this._updateOutput("More results", 9));
64+
index += 1;
65+
}
6066
}
6167

6268
if(index > 9){
63-
moreContent.appendChild(this._updateOutput(label, index));
69+
let value = Math.floor((index - 1)/9);
70+
let span = moreContent.querySelector(`[id=${CSS.escape(value)}]`);
71+
span.appendChild(this._updateOutput(label, index));
6472
} else {
6573
body.appendChild(this._updateOutput(label, index));
6674
}

0 commit comments

Comments
 (0)