Works with the shadow DOM disabled.

This commit is contained in:
Ben Ogle
2014-11-11 16:30:22 -08:00
parent 9acea88101
commit 97a671cb49
2 changed files with 9 additions and 7 deletions

View File

@@ -66,8 +66,10 @@ LinesComponent = React.createClass
insertionPoint = document.createElement('content')
insertionPoint.setAttribute('select', 'atom-overlay')
@overlayManager = new OverlayManager()
@overlayManager = new OverlayManager(@props.hostElement)
@getDOMNode().appendChild(insertionPoint)
else
@overlayManager = new OverlayManager(@getDOMNode())
shouldComponentUpdate: (newProps) ->
return true unless isEqualForProperties(newProps, @props,

View File

@@ -1,10 +1,10 @@
module.exports =
class OverlayManager
constructor: ->
constructor: (@container)->
@overlays = {}
render: (props) ->
{hostElement, editor, overlayDecorations, lineHeightInPixels} = props
{editor, overlayDecorations, lineHeightInPixels} = props
existingDecorations = null
for markerId, {isMarkerReversed, startPixelPosition, endPixelPosition, decorations} of overlayDecorations
@@ -13,24 +13,24 @@ class OverlayManager
startPixelPosition
else
endPixelPosition
@renderOverlay(editor, hostElement, decoration, pixelPosition, lineHeightInPixels)
@renderOverlay(editor, decoration, pixelPosition, lineHeightInPixels)
existingDecorations ?= {}
existingDecorations[decoration.id] = true
for id, overlay of @overlays
unless existingDecorations? and id of existingDecorations
hostElement.removeChild(overlay)
@container.removeChild(overlay)
delete @overlays[id]
return
renderOverlay: (editor, hostElement, decoration, pixelPosition, lineHeightInPixels) ->
renderOverlay: (editor, decoration, pixelPosition, lineHeightInPixels) ->
item = atom.views.getView(decoration.item)
unless overlay = @overlays[decoration.id]
overlay = @overlays[decoration.id] = document.createElement('atom-overlay')
overlay.appendChild(item)
hostElement.appendChild(overlay)
@container.appendChild(overlay)
itemWidth = item.offsetWidth
itemHeight = item.offsetHeight