diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index a60f85fc..5846e7bc 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -1,6 +1,6 @@ {debounce} = require 'underscore-plus' {CompositeDisposable, Disposable} = require 'event-kit' -{EventsDelegation} = require 'atom-utils' +{EventsDelegation, AncestorsMethods} = require 'atom-utils' DOMStylesReader = require './mixins/dom-styles-reader' CanvasDrawer = require './mixins/canvas-drawer' @@ -22,6 +22,7 @@ class MinimapElement extends HTMLElement DOMStylesReader.includeInto(this) CanvasDrawer.includeInto(this) EventsDelegation.includeInto(this) + AncestorsMethods.includeInto(this) ### Public ### @@ -90,6 +91,7 @@ class MinimapElement extends HTMLElement @measureHeightAndWidth() @updateMinimapFlexPosition() @attached = true + @attachedToTextEditor = @parentNode is @getTextEditorElementRoot() # Uses of `atom.styles.onDidAddStyleElement` instead of # `atom.themes.onDidChangeActiveThemes`. @@ -332,7 +334,6 @@ 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' diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index 66febc74..1923d2f7 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -130,6 +130,9 @@ describe 'MinimapElement', -> # and not 20px expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.clientWidth / 11, 0) + it 'knows when attached to a text editor', -> + expect(minimapElement.attachedToTextEditor).toBeTruthy() + it 'resizes the canvas to fit the minimap', -> expect(canvas.offsetHeight / devicePixelRatio).toBeCloseTo(minimapElement.offsetHeight + minimap.getLineHeight(), 0) expect(canvas.offsetWidth / devicePixelRatio).toBeCloseTo(minimapElement.offsetWidth, 0)