Fix highlight positioning when scrolling
This commit is contained in:
parent
ad13e9849f
commit
5d8b620abc
@ -699,7 +699,6 @@ class BesService {
|
|||||||
* @param {*} match Grammar checking rule match
|
* @param {*} match Grammar checking rule match
|
||||||
*/
|
*/
|
||||||
highlightMistake(match) {
|
highlightMistake(match) {
|
||||||
// TODO: Če sta 2 napaki v istem rectu, se prikaže samo zgornja/zadnja (oz. tista, ki jo uporabnik klikne). To pa pomeni, da se lahko podčrtana barva razlikuje od "highlight" barve.
|
|
||||||
match.highlights.forEach(rect => {
|
match.highlights.forEach(rect => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
el.classList.add('bes-highlight-rect')
|
el.classList.add('bes-highlight-rect')
|
||||||
@ -708,8 +707,8 @@ class BesService {
|
|||||||
? 'bes-highlight-spelling-rect'
|
? 'bes-highlight-spelling-rect'
|
||||||
: 'bes-highlight-grammar-rect'
|
: 'bes-highlight-grammar-rect'
|
||||||
)
|
)
|
||||||
el.style.left = `${rect.x}px`
|
el.style.left = `${rect.x + window.scrollX}px`
|
||||||
el.style.top = `${rect.y}px`
|
el.style.top = `${rect.y + window.scrollY}px`
|
||||||
el.style.width = `${rect.width}px`
|
el.style.width = `${rect.width}px`
|
||||||
el.style.height = `${rect.height}px`
|
el.style.height = `${rect.height}px`
|
||||||
document.body.appendChild(el)
|
document.body.appendChild(el)
|
||||||
@ -1792,7 +1791,6 @@ class BesPlainTextService extends BesService {
|
|||||||
for (let m of result.matches) {
|
for (let m of result.matches) {
|
||||||
for (let rect of m.highlights) {
|
for (let rect of m.highlights) {
|
||||||
if (BesService.isPointInRect(source.clientX, source.clientY, rect)) {
|
if (BesService.isPointInRect(source.clientX, source.clientY, rect)) {
|
||||||
console.log(result.range)
|
|
||||||
pointsInRect.push({ el: result.range, match: m })
|
pointsInRect.push({ el: result.range, match: m })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user