private _setMarkersVisibility()

in packages/layers/label/src/LabelLayer.ts [463:506]


	private _setMarkersVisibility(timeline) {
		const duration = this.getProps('showHideDuration')
		const markers = this.markers
		const lastInvisibles = new Set<SimplifiedMarker>()
		const lastVisibles = new Set<SimplifiedMarker>()
		const needsHide = new Set<SimplifiedMarker>()
		markers.forEach((marker) => {
			if (!marker) return
			if (marker.labelVisible === false) {
				lastInvisibles.add(marker)
			} else {
				lastVisibles.add(marker)
			}
			marker.labelVisible = true
		})
		// check markers bbox intersections with each other
		// hide the less important one if two boxes are intersected
		for (let i = 0; i < markers.length; i++) {
			const a = markers[i]
			if (!a) continue
			if (a.labelVisible === false) continue
			for (let j = i + 1; j < markers.length; j++) {
				const b = markers[j]
				if (!b) continue
				if (b.labelVisible === false) continue
				// Intersection detection
				if (a.labelBox.intersectsBox(b.labelBox)) {
					b.labelVisible = false
					needsHide.add(b)
				}
			}
		}
		// show/hide animation
		needsHide.forEach((marker) => {
			if (lastVisibles.has(marker)) {
				this._hideMarker(marker, timeline, duration)
			}
		})
		lastInvisibles.forEach((marker) => {
			if (marker.labelVisible === true) {
				this._showMarker(marker, timeline, duration)
			}
		})
	}