MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / scheduleRefresh

Function scheduleRefresh

src/components/Tooltip/anchor-registry.ts:79–113  ·  view source on GitHub ↗
(affectedTooltipIds: Set<string> | null)

Source from the content-addressed store, hash-verified

77let pendingFullRefresh = false
78
79function scheduleRefresh(affectedTooltipIds: Set<string> | null) {
80 if (affectedTooltipIds) {
81 if (!pendingTooltipIds) {
82 pendingTooltipIds = new Set()
83 }
84 affectedTooltipIds.forEach((id) => pendingTooltipIds!.add(id))
85 } else {
86 pendingFullRefresh = true
87 }
88
89 if (refreshScheduled) {
90 return
91 }
92 refreshScheduled = true
93
94 const flush = () => {
95 refreshScheduled = false
96 const fullRefresh = pendingFullRefresh
97 const ids = pendingTooltipIds
98 pendingFullRefresh = false
99 pendingTooltipIds = null
100
101 if (fullRefresh) {
102 refreshAllEntries()
103 } else if (ids && ids.size > 0) {
104 refreshEntriesForTooltipIds(ids)
105 }
106 }
107
108 if (typeof requestAnimationFrame === 'function') {
109 requestAnimationFrame(flush)
110 } else {
111 Promise.resolve().then(flush)
112 }
113}
114
115/**
116 * Only refresh entries whose tooltipId is in the affected set,

Callers 1

ensureDocumentObserverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected