Skip to content

Commit

Permalink
💩 So WebKitCSSMatrix is broken in Chrome 45
Browse files Browse the repository at this point in the history
So I have to use top/left positioning in tests to make sure the good
offsets are computed.
  • Loading branch information
abe33 committed Oct 30, 2015
1 parent 3bb81d3 commit 6495df2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
32 changes: 24 additions & 8 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,17 @@ class MinimapElement extends HTMLElement
visibleAreaTop = @minimap.getTextEditorScaledScrollTop() - @minimap.getScrollTop()
visibleWidth = Math.min(@canvas.width / devicePixelRatio, @width)

@applyStyles @visibleArea,
width: visibleWidth + 'px'
height: @minimap.getTextEditorScaledHeight() + 'px'
transform: @makeTranslate(visibleAreaLeft, visibleAreaTop)
if atom.inSpecMode()
@applyStyles @visibleArea,
width: visibleWidth + 'px'
height: @minimap.getTextEditorScaledHeight() + 'px'
top: visibleAreaTop + 'px'
left: visibleAreaLeft + 'px'
else
@applyStyles @visibleArea,
width: visibleWidth + 'px'
height: @minimap.getTextEditorScaledHeight() + 'px'
transform: @makeTranslate(visibleAreaLeft, visibleAreaTop)

@applyStyles @controls,
width: visibleWidth + 'px'
Expand All @@ -355,7 +362,11 @@ class MinimapElement extends HTMLElement

canvasTransform = @makeTranslate(0, canvasTop)
canvasTransform += " " + @makeScale(1 / devicePixelRatio) if devicePixelRatio isnt 1
@applyStyles @canvas, transform: canvasTransform

if atom.inSpecMode()
@applyStyles @canvas, top: canvasTop + 'px'
else
@applyStyles @canvas, transform: canvasTransform

if @minimapScrollIndicator and @minimap.canScroll() and not @scrollIndicator
@initializeScrollIndicator()
Expand All @@ -365,9 +376,14 @@ class MinimapElement extends HTMLElement
indicatorHeight = minimapScreenHeight * (minimapScreenHeight / @minimap.getHeight())
indicatorScroll = (minimapScreenHeight - indicatorHeight) * @minimap.getCapedTextEditorScrollRatio()

@applyStyles @scrollIndicator,
height: indicatorHeight + 'px'
transform: @makeTranslate(0, indicatorScroll)
if atom.inSpecMode()
@applyStyles @scrollIndicator,
height: indicatorHeight + 'px'
top: indicatorScroll + 'px'
else
@applyStyles @scrollIndicator,
height: indicatorHeight + 'px'
transform: @makeTranslate(0, indicatorScroll)

@disposeScrollIndicator() if not @minimap.canScroll()

Expand Down
10 changes: 6 additions & 4 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ stylesheetPath = path.resolve __dirname, '..', 'styles', 'minimap.less'
stylesheet = atom.themes.loadStylesheet(stylesheetPath)

realOffsetTop = (o) ->
transform = new WebKitCSSMatrix window.getComputedStyle(o).transform
o.offsetTop + transform.m42
# transform = new WebKitCSSMatrix window.getComputedStyle(o).transform
# o.offsetTop + transform.m42
o.offsetTop

realOffsetLeft = (o) ->
transform = new WebKitCSSMatrix window.getComputedStyle(o).transform
o.offsetLeft + transform.m41
# transform = new WebKitCSSMatrix window.getComputedStyle(o).transform
# o.offsetLeft + transform.m41
o.offsetLeft

isVisible = (node) -> node.offsetWidth > 0 or node.offsetHeight > 0

Expand Down

0 comments on commit 6495df2

Please sign in to comment.