diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index e53e29b0..e23e7de8 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -144,6 +144,8 @@ class MinimapElement extends HTMLElement else @width = @clientWidth + return unless @isVisible() + if @width isnt @canvas.width or @height isnt @canvas.height @canvas.width = @width * devicePixelRatio @canvas.height = (@height + @minimap.getLineHeight()) * devicePixelRatio @@ -178,7 +180,7 @@ class MinimapElement extends HTMLElement @requestUpdate() update: -> - return unless @attached + return unless @attached and @isVisible() if @adjustToSoftWrap @style.width = @width + 'px' @@ -211,6 +213,8 @@ class MinimapElement extends HTMLElement @updateCanvas() + isVisible: -> @offsetWidth > 0 or @offsetHeight > 0 + transformElement: (el, transform) -> el.style.transform = transform diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index d2d35a69..aa446802 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -15,7 +15,7 @@ realOffsetLeft = (o) -> transform = new WebKitCSSMatrix window.getComputedStyle(o).transform o.offsetLeft + transform.m41 -describe 'MinimapElement', -> +fdescribe 'MinimapElement', -> [editor, minimap, largeSample, mediumSample, smallSample, jasmineContent, editorElement, minimapElement] = [] beforeEach -> @@ -220,6 +220,17 @@ describe 'MinimapElement', -> expect(minimapElement.drawLines.calls[1].args[1]).toEqual(100) expect(minimapElement.drawLines.calls[1].args[2]).toEqual(101) + ffdescribe 'when the editor visibility change', -> + it 'does not modify the size of the canvas', -> + canvasWidth = minimapElement.canvas.width + canvasHeight = minimapElement.canvas.height + editorElement.style.display = 'none' + advanceClock(150) + nextAnimationFrame() + + expect(minimapElement.canvas.width).toEqual(canvasWidth) + expect(minimapElement.canvas.height).toEqual(canvasHeight) + # ###### ####### ## ## ######## #### ###### # ## ## ## ## ### ## ## ## ## ## # ## ## ## #### ## ## ## ##