mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Use 'blink-off' css class to blink the cursor when editor is focused
Rather than managing the visibility directly, a class makes it easy. The cursors will always be toggling this class on and off in the background, but only on the focused editor will it actually have an effect.
This commit is contained in:
@@ -914,11 +914,11 @@ describe "Editor", ->
|
||||
|
||||
editor.setSelectedBufferRange([[0, 0], [3, 0]])
|
||||
expect(editor.getSelection().isEmpty()).toBeFalsy()
|
||||
expect(cursorView.css('visibility')).toBe 'hidden'
|
||||
expect(cursorView).toBeHidden()
|
||||
|
||||
editor.setCursorBufferPosition([1, 3])
|
||||
expect(editor.getSelection().isEmpty()).toBeTruthy()
|
||||
expect(cursorView.css('visibility')).toBe 'visible'
|
||||
expect(cursorView).toBeVisible()
|
||||
|
||||
describe "auto-scrolling", ->
|
||||
it "only auto-scrolls when the last cursor is moved", ->
|
||||
@@ -1773,10 +1773,10 @@ describe "Editor", ->
|
||||
|
||||
editor.setCursorScreenPosition([2,0])
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected')
|
||||
expect(editor.find('.cursor').css('visibility')).toBe 'hidden'
|
||||
expect(editor.find('.cursor')).toBeHidden()
|
||||
|
||||
editor.setCursorScreenPosition([3,0])
|
||||
expect(editor.find('.cursor').css('visibility')).toBe 'visible'
|
||||
expect(editor.find('.cursor')).toBeVisible()
|
||||
|
||||
describe "when a selected fold is scrolled into view (and the fold line was not previously rendered)", ->
|
||||
it "renders the fold's line element with the 'selected' class", ->
|
||||
|
||||
@@ -61,22 +61,16 @@ class CursorView extends View
|
||||
setVisible: (visible) ->
|
||||
unless @visible == visible
|
||||
@visible = visible
|
||||
if @visible
|
||||
@css('visibility', '')
|
||||
else
|
||||
@css('visibility', 'hidden')
|
||||
|
||||
toggleVisible: ->
|
||||
@setVisible(not @visible)
|
||||
@toggle(@visible)
|
||||
|
||||
stopBlinking: ->
|
||||
clearInterval(@blinkInterval) if @blinkInterval
|
||||
@blinkInterval = null
|
||||
@setVisible(@cursor.isVisible())
|
||||
this[0].classList.remove('blink-off')
|
||||
|
||||
startBlinking: ->
|
||||
return if @blinkInterval?
|
||||
blink = => @toggleVisible() if @cursor.isVisible()
|
||||
blink = => @toggleClass('blink-off')
|
||||
@blinkInterval = setInterval(blink, @blinkPeriod / 2)
|
||||
|
||||
resetBlinking: ->
|
||||
|
||||
Reference in New Issue
Block a user