Popper position update (#212)
This commit is contained in:
parent
5f40bb8465
commit
5d116ede22
|
@ -134,7 +134,9 @@ export const FullArticle = (props: Props) => {
|
||||||
const tooltipElements: NodeListOf<HTMLElement> = document.querySelectorAll(
|
const tooltipElements: NodeListOf<HTMLElement> = document.querySelectorAll(
|
||||||
'[data-toggle="tooltip"], footnote'
|
'[data-toggle="tooltip"], footnote'
|
||||||
)
|
)
|
||||||
if (!tooltipElements) return
|
if (!tooltipElements) {
|
||||||
|
return
|
||||||
|
}
|
||||||
tooltipElements.forEach((element) => {
|
tooltipElements.forEach((element) => {
|
||||||
const tooltip = document.createElement('div')
|
const tooltip = document.createElement('div')
|
||||||
tooltip.classList.add(styles.tooltip)
|
tooltip.classList.add(styles.tooltip)
|
||||||
|
@ -149,7 +151,8 @@ export const FullArticle = (props: Props) => {
|
||||||
if (element.hasAttribute('href')) {
|
if (element.hasAttribute('href')) {
|
||||||
element.setAttribute('href', 'javascript: void(0);')
|
element.setAttribute('href', 'javascript: void(0);')
|
||||||
}
|
}
|
||||||
createPopper(element, tooltip, {
|
|
||||||
|
const popperInstance = createPopper(element, tooltip, {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
modifiers: [
|
modifiers: [
|
||||||
{
|
{
|
||||||
|
@ -161,13 +164,16 @@ export const FullArticle = (props: Props) => {
|
||||||
options: {
|
options: {
|
||||||
offset: [0, 8]
|
offset: [0, 8]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'flip',
|
||||||
|
options: { fallbackPlacements: ['top'] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
tooltip.style.visibility = 'hidden'
|
tooltip.style.visibility = 'hidden'
|
||||||
let isTooltipVisible = false
|
let isTooltipVisible = false
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (isTooltipVisible) {
|
if (isTooltipVisible) {
|
||||||
tooltip.style.visibility = 'hidden'
|
tooltip.style.visibility = 'hidden'
|
||||||
|
@ -176,6 +182,8 @@ export const FullArticle = (props: Props) => {
|
||||||
tooltip.style.visibility = 'visible'
|
tooltip.style.visibility = 'visible'
|
||||||
isTooltipVisible = true
|
isTooltipVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popperInstance.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDocumentClick = (e) => {
|
const handleDocumentClick = (e) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user