lib/multi-wrap-guide-view.js
// Mouse move event handler, updates position and tip text.
Mouse move event handler, updates position and tip text.
Mouse move event handler updates position and tip text .
mouseMoveGuide (guide, event) {
    let offset, position, width
    const [offsetLeft, offsetTop] = Array.from(this.offsetFromMouseEvent(event))
    const isHorizontal = guide.parentElement.classList.contains('horizontal')
    if (isHorizontal) {
      const targetTop = offsetTop
      guide.style.top = `${targetTop}px`
      offset = parseInt(guide.style.top) + this.editorElement.getScrollTop()
      width = this.editor.getLineHeightInPixels()
    } else {
      const targetLeft = offsetLeft
      guide.style.left = `${targetLeft}px`
      offset = parseInt(guide.style.left) + this.editorElement.getScrollLeft()
      width = this.editorElement.getDefaultCharacterWidth()
    }
    const prev = (Math.floor(offset / width)) * width
    const next = (Math.floor(offset / width) + 1) * width
    if (Math.abs(offset - prev) < Math.abs(offset - next)) {
      position = Math.floor(prev / width)
    } else {
      position = Math.floor(next / width)
    }
    if (isHorizontal) {
      position = this.editor.bufferRowForScreenRow(position)
    }
    guide.querySelector('div.multi-wrap-guide-tip').textContent = position
    return false
  }
mouseMoveGuide ( guide , event ) { let offset , position , width const [ offsetLeft , offsetTop ] = Array . from ( this . offsetFromMouseEvent ( event ) ) const isHorizontal = guide . parentElement . classList . contains ( 'horizontal' ) if ( isHorizontal ) { const targetTop = offsetTop guide . style . top = ` ${ targetTop } ` offset = parseInt ( guide . style . top ) + this . editorElement . getScrollTop ( ) width = this . editor . getLineHeightInPixels ( ) } else { const targetLeft = offsetLeft guide . style . left = ` ${ targetLeft } ` offset = parseInt ( guide . style . left ) + this . editorElement . getScrollLeft ( ) width = this . editorElement . getDefaultCharacterWidth ( ) } const prev = ( Math . floor ( offset / width ) ) * width const next = ( Math . floor ( offset / width ) + 1 ) * width if ( Math . abs ( offset - prev ) < Math . abs ( offset - next ) ) { position = Math . floor ( prev / width ) } else { position = Math . floor ( next / width ) } if ( isHorizontal ) { position = this . editor . bufferRowForScreenRow ( position ) } guide . querySelector ( 'div.multi-wrap-guide-tip' ) . textContent = position return false }
Mouse move event handler, updates position and tip text.
Mouse move event handler updates position and tip text .