mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Previously, SelectionsComponenet::shouldComponentUpdate was storing the ranges for selections as a side effect. We also were passing boolean values (cursorMoved and selectionUpdated) to determine if these components should update. Now, we compute a simple hash of screen ranges for selections and cursors in the root component and pass them down. This simplifies shouldComponentUpdate for selections and allows us to implement one for cursors.
16 lines
486 B
CoffeeScript
16 lines
486 B
CoffeeScript
React = require 'react-atom-fork'
|
|
{div} = require 'reactionary-atom-fork'
|
|
|
|
module.exports =
|
|
CursorComponent = React.createClass
|
|
displayName: 'CursorComponent'
|
|
|
|
render: ->
|
|
{editor, screenRange, scrollTop, scrollLeft} = @props
|
|
{top, left, height, width} = editor.pixelRectForScreenRange(screenRange)
|
|
top -= scrollTop
|
|
left -= scrollLeft
|
|
WebkitTransform = "translate3d(#{left}px, #{top}px, 0px)"
|
|
|
|
div className: 'cursor', style: {height, width, WebkitTransform}
|