Skip to content

Commit

Permalink
🐎 Replace sequencial styles affectation with cssText
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 21, 2014
1 parent 1c0c07a commit f12ae20
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,18 @@ class MinimapElement extends HTMLElement
visibleAreaLeft = @minimap.getTextEditorScrollLeft()
visibleAreaTop = @minimap.getTextEditorScrollTop() - @minimap.getMinimapScrollTop()

@visibleArea.style.width = @clientWidth + 'px'
@visibleArea.style.height = @minimap.getTextEditorHeight() + 'px'
@transformElement @visibleArea, @makeTranslate(visibleAreaLeft, visibleAreaTop)
@applyStyles @visibleArea,
width: @clientWidth + 'px'
height: @minimap.getTextEditorHeight() + 'px'
transform: @makeTranslate(visibleAreaLeft, visibleAreaTop)

@controls.style.width = @canvas.width + 'px'
@applyStyles @controls,
width: @canvas.width + 'px'

canvasTop = @minimap.getFirstVisibleScreenRow() * @minimap.getLineHeight() - @minimap.getMinimapScrollTop()

@transformElement(@canvas, @makeTranslate(0, canvasTop))
@applyStyles @canvas,
transform: @makeTranslate(0, canvasTop)

if @minimapScrollIndicator and @minimap.canScroll() and not @scrollIndicator
@initializeScrollIndicator()
Expand All @@ -269,8 +272,10 @@ class MinimapElement extends HTMLElement
editorHeight = @getTextEditor().getHeight()
indicatorHeight = editorHeight * (editorHeight / @minimap.getHeight())
indicatorScroll = (editorHeight - indicatorHeight) * @minimap.getCapedTextEditorScrollRation()
@scrollIndicator.style.height = indicatorHeight + 'px'
@transformElement @scrollIndicator, @makeTranslate(0, indicatorScroll)

@applyStyles @scrollIndicator,
height: indicatorHeight + 'px'
transform: @makeTranslate(0, indicatorScroll)

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

Expand Down Expand Up @@ -386,8 +391,13 @@ class MinimapElement extends HTMLElement
# ## ## ## ## ## ##
# ###### ###### ######

transformElement: (el, transform) ->
el.style.transform = transform
applyStyles: (element, styles) ->
cssText = ''

for property,value of styles
cssText += "#{property}: #{value}; "

element.style.cssText = cssText

makeTranslate: (x=0,y=0) ->
if @useHardwareAcceleration
Expand Down

0 comments on commit f12ae20

Please sign in to comment.