mirror of
https://github.com/umap-project/umap.git
synced 2025-05-01 04:22:24 +02:00
Compare commits
2 commits
53072b6f5b
...
4f2f98bdb7
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4f2f98bdb7 | ||
![]() |
28adb1c535 |
1 changed files with 0 additions and 46 deletions
|
@ -1,46 +0,0 @@
|
||||||
export class DataLayerManager extends Object {
|
|
||||||
add(datalayer) {
|
|
||||||
this[datalayer.id] = datalayer
|
|
||||||
}
|
|
||||||
active() {
|
|
||||||
return Object.values(this)
|
|
||||||
.filter((datalayer) => !datalayer.isDeleted)
|
|
||||||
.sort((a, b) => a.options.rank > b.options.rank)
|
|
||||||
}
|
|
||||||
reverse() {
|
|
||||||
return this.active().reverse()
|
|
||||||
}
|
|
||||||
count() {
|
|
||||||
return this.active().length
|
|
||||||
}
|
|
||||||
find(func) {
|
|
||||||
for (const datalayer of this.reverse()) {
|
|
||||||
if (func.call(datalayer, datalayer)) {
|
|
||||||
return datalayer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filter(func) {
|
|
||||||
return this.active().filter(func)
|
|
||||||
}
|
|
||||||
visible() {
|
|
||||||
return this.filter((datalayer) => datalayer.isVisible())
|
|
||||||
}
|
|
||||||
browsable() {
|
|
||||||
return this.reverse().filter((datalayer) => datalayer.allowBrowse())
|
|
||||||
}
|
|
||||||
prev(datalayer) {
|
|
||||||
const browsable = this.browsable()
|
|
||||||
const current = browsable.indexOf(datalayer)
|
|
||||||
const prev = browsable[current - 1] || browsable[browsable.length - 1]
|
|
||||||
if (!prev.canBrowse()) return this.prev(prev)
|
|
||||||
return prev
|
|
||||||
}
|
|
||||||
next(datalayer) {
|
|
||||||
const browsable = this.browsable()
|
|
||||||
const current = browsable.indexOf(datalayer)
|
|
||||||
const next = browsable[current + 1] || browsable[0]
|
|
||||||
if (!next.canBrowse()) return this.next(next)
|
|
||||||
return next
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue