Fix scrollIntoView behavior and improve popup positioning #4
This commit is contained in:
parent
a04ffb3e70
commit
3cd86bf4c3
18
service.js
18
service.js
@ -1200,17 +1200,25 @@ class BesService {
|
|||||||
service.activeMatchIndex = next
|
service.activeMatchIndex = next
|
||||||
const { el, match } = service.sortedMatches[next]
|
const { el, match } = service.sortedMatches[next]
|
||||||
|
|
||||||
// Not the cleanest solution, but it is good enough for now
|
if (el && typeof el.scrollIntoView === 'function') {
|
||||||
el.scrollIntoView({ behavior: 'instant' })
|
el.scrollIntoView({ behavior: 'instant', block: 'center' })
|
||||||
|
}
|
||||||
|
// Not the cleanest solution to setTimeout()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
service.dismissPopup()
|
service.dismissPopup()
|
||||||
const popup = document.querySelector('bes-popup-el')
|
const popup = document.querySelector('bes-popup-el')
|
||||||
BesPopup.clearReplacements()
|
BesPopup.clearReplacements()
|
||||||
popup.setContent(el, match, service, service.isContentEditable())
|
popup.setContent(el, match, service, service.isContentEditable())
|
||||||
service.highlightMistake(match)
|
service.highlightMistake(match)
|
||||||
match.highlights.forEach(el => {
|
const containerRect = service.hostElement.getBoundingClientRect()
|
||||||
const clientY = `${el.y + 150}`
|
match.highlights.forEach(rect => {
|
||||||
popup.show(el.x, clientY, service)
|
const clientX = rect.x + containerRect.left
|
||||||
|
const clientY =
|
||||||
|
rect.y +
|
||||||
|
containerRect.top +
|
||||||
|
rect.height -
|
||||||
|
service.hostElement.scrollTop
|
||||||
|
popup.show(clientX, clientY, service)
|
||||||
})
|
})
|
||||||
}, 150)
|
}, 150)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user