Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
boschDev committed May 19, 2020
1 parent 5ce6af2 commit 8ac0edc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/plugins/sync-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ const isDomSelectionInView = () => {
const anchorElement = getElementFromTextNode(selection.anchorNode)
if (selection && isInViewport(anchorElement)) {
const focusElement = getElementFromTextNode(selection.focusNode)
if (focusElement === anchorElement
|| focusElement === selection.anchorNode
|| selection.focusNode === focusElement
|| selection.focusNode === selection.anchorNode
|| isInViewport(focusElement)
if (focusElement === anchorElement ||
focusElement === selection.anchorNode ||
selection.focusNode === focusElement ||
selection.focusNode === selection.anchorNode ||
isInViewport(focusElement)
) {
return true
}
Expand All @@ -208,9 +208,9 @@ const isDomSelectionInView = () => {
const isInViewport = element => {
const bounding = element.getBoundingClientRect()
const documentElement = dom.doc.documentElement
return bounding.top >= 0 && bounding.left >= 0
&& bounding.bottom <= (window.innerHeight || documentElement.clientHeight)
&& bounding.right <= (window.innerWidth || documentElement.clientWidth)
return bounding.top >= 0 && bounding.left >= 0 &&
bounding.right <= (window.innerWidth || documentElement.clientWidth) &&
bounding.bottom <= (window.innerHeight || documentElement.clientHeight)
}

/**
Expand Down Expand Up @@ -254,11 +254,13 @@ export class ProsemirrorBinding {
this._domSelectionInView = null
}

_isLocalCursorInView() {
_isLocalCursorInView () {
if (!this.prosemirrorView.hasFocus()) return false
if (environment.isBrowser && this._domSelectionInView === null) {
// Calculte the domSelectionInView and clear by next tick after all events are finished
setTimeout(() => this._domSelectionInView = null, 0)
setTimeout(() => {
this._domSelectionInView = null
}, 0)
this._domSelectionInView = isDomSelectionInView()
}
return this._domSelectionInView
Expand Down

0 comments on commit 8ac0edc

Please sign in to comment.