From 8c066eee35694320687b157de5fbb8bd3f3e447d Mon Sep 17 00:00:00 2001 From: abe33 Date: Tue, 6 Jan 2015 23:41:23 +0100 Subject: [PATCH] :bug: Fix minimap canvas scaling when device pixel ratio > 1 Fixes #192 --- lib/minimap-element.coffee | 11 +++++++++-- stylesheets/minimap.less | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index bddc309d..f4b660c9 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -262,8 +262,9 @@ class MinimapElement extends HTMLElement canvasTop = @minimap.getFirstVisibleScreenRow() * @minimap.getLineHeight() - @minimap.getMinimapScrollTop() - @applyStyles @canvas, - transform: @makeTranslate(0, canvasTop) + canvasTransform = @makeTranslate(0, canvasTop) + canvasTransform += " " + @makeScale(1/devicePixelRatio) if devicePixelRatio isnt 1 + @applyStyles @canvas, transform: canvasTransform if @minimapScrollIndicator and @minimap.canScroll() and not @scrollIndicator @initializeScrollIndicator() @@ -405,6 +406,12 @@ class MinimapElement extends HTMLElement else "translate(#{x}px, #{y}px)" + makeScale: (x=0,y=x) -> + if @useHardwareAcceleration + "scale3d(#{x}, #{y}, 1)" + else + "scale(#{x}, #{y})" + # ######## ## ######## ## ## ######## ## ## ######## # ## ## ## ### ### ## ### ## ## # ## ## ## #### #### ## #### ## ## diff --git a/stylesheets/minimap.less b/stylesheets/minimap.less index f25c3011..7c118a9c 100644 --- a/stylesheets/minimap.less +++ b/stylesheets/minimap.less @@ -25,6 +25,7 @@ atom-text-editor::shadow, atom-text-editorĀ { position: absolute; top: 0; left: 0; + transform-origin: 0 0; } .minimap-visible-area {