Skip to content

Commit 60ef1a6

Browse files
authored
Merge pull request #745 from atom-minimap/canvas-drawer-free
2 parents b3fc577 + 6999bc5 commit 60ef1a6

File tree

4 files changed

+143
-136
lines changed

4 files changed

+143
-136
lines changed

lib/minimap-element.js

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { EventsDelegation, AncestorsMethods } from 'atom-utils-plus'
55
import elementResizeDetectorImport from 'element-resize-detector'
66

77
import * as Main from './main'
8-
import DOMStylesReader from './dom-styles-reader'
98
import CanvasDrawer from './mixins/canvas-drawer'
109
import include from './decorators/include'
1110
import element from './decorators/element'
@@ -83,10 +82,7 @@ class MinimapElement {
8382
* @access private
8483
*/
8584
this.minimap = undefined
86-
/**
87-
* @access private
88-
*/
89-
this.editorElement = undefined
85+
9086
/**
9187
* @access private
9288
*/
@@ -181,11 +177,6 @@ class MinimapElement {
181177
*/
182178
this.quickSettingsElement = undefined
183179

184-
/**
185-
* This MinimapElement's DOMStylesReader
186-
*/
187-
this.DOMStylesReader = new DOMStylesReader()
188-
189180
// States
190181

191182
/**
@@ -379,10 +370,10 @@ class MinimapElement {
379370
this.measureHeightAndWidth()
380371
this.updateMinimapFlexPosition()
381372
this.attached = true
382-
this.attachedToTextEditor = this.queryParentSelector('atom-text-editor') === this.getTextEditorElement()
373+
this.attachedToTextEditor = this.queryParentSelector('atom-text-editor') === this.minimap.getTextEditorElement()
383374

384375
if (this.attachedToTextEditor) {
385-
this.getTextEditorElement().setAttribute('with-minimap', '')
376+
this.minimap.getTextEditorElement().setAttribute('with-minimap', '')
386377
}
387378

388379
this.subscriptions.add(
@@ -408,7 +399,7 @@ class MinimapElement {
408399
* @access private
409400
*/
410401
detachedCallback () {
411-
this.getTextEditorElement().removeAttribute('with-minimap')
402+
this.minimap.getTextEditorElement().removeAttribute('with-minimap')
412403
this.attached = false
413404
}
414405

@@ -442,7 +433,7 @@ class MinimapElement {
442433
attach (parent) {
443434
if (this.attached) { return }
444435

445-
const container = parent || this.getTextEditorElement()
436+
const container = parent || this.minimap.getTextEditorElement()
446437
const minimaps = container.querySelectorAll('atom-text-editor-minimap')
447438
if (minimaps.length) {
448439
Array.prototype.forEach.call(minimaps, (el) => { el.destroy() })
@@ -666,25 +657,6 @@ class MinimapElement {
666657
delete this.openQuickSettings
667658
}
668659

669-
/**
670-
* Returns the target `TextEditor` of the Minimap.
671-
*
672-
* @return {TextEditor} the minimap's text editor
673-
*/
674-
getTextEditor () { return this.minimap.getTextEditor() }
675-
676-
/**
677-
* Returns the `TextEditorElement` for the Minimap's `TextEditor`.
678-
*
679-
* @return {TextEditorElement} the minimap's text editor element
680-
*/
681-
getTextEditorElement () {
682-
if (this.editorElement) { return this.editorElement }
683-
684-
this.editorElement = atom.views.getView(this.getTextEditor())
685-
return this.editorElement
686-
}
687-
688660
// ## ## ####### ######## ######## ##
689661
// ### ### ## ## ## ## ## ##
690662
// #### #### ## ## ## ## ## ##
@@ -1088,7 +1060,7 @@ class MinimapElement {
10881060
const row = Math.floor(deltaY / this.minimap.getLineHeight()) + this.minimap.getFirstVisibleScreenRow()
10891061

10901062
const textEditor = this.minimap.getTextEditor()
1091-
const textEditorElement = this.getTextEditorElement()
1063+
const textEditorElement = this.minimap.getTextEditorElement()
10921064

10931065
const scrollTop = row * textEditor.getLineHeightInPixels() - this.minimap.getTextEditorHeight() / 2
10941066
const textEditorScrollTop = textEditorElement.pixelPositionForScreenPosition([row, 0]).top - this.minimap.getTextEditorHeight() / 2

lib/minimap.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ export default class Minimap {
4646
* @access private
4747
*/
4848
this.textEditor = options.textEditor
49+
50+
/**
51+
* The Minimap's text editor element.
52+
* @access private
53+
*/
54+
this.editorElement = undefined
55+
4956
/**
5057
* The stand-alone state of the current Minimap.
5158
*
@@ -525,6 +532,18 @@ export default class Minimap {
525532
*/
526533
getTextEditor () { return this.textEditor }
527534

535+
/**
536+
* Returns the `TextEditorElement` for the Minimap's `TextEditor`.
537+
*
538+
* @return {TextEditorElement} the minimap's text editor element
539+
*/
540+
getTextEditorElement () {
541+
if (this.editorElement) { return this.editorElement }
542+
543+
this.editorElement = atom.views.getView(this.getTextEditor())
544+
return this.editorElement
545+
}
546+
528547
/**
529548
* Returns the height of the `TextEditor` at the Minimap scale.
530549
*

0 commit comments

Comments
 (0)