Skip to content

Commit 1df5060

Browse files
authored
Merge pull request #783 from UziTech/left-width
2 parents 64ee4b0 + 78c8985 commit 1df5060

File tree

4 files changed

+13
-58
lines changed

4 files changed

+13
-58
lines changed

lib/canvas-layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use babel"
1+
/** @babel */
22
"use strict"
33

44
/**

lib/minimap-element.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,6 @@ import element from "./decorators/element"
1313
import MinimapQuickSettingsElement from "./minimap-quick-settings-element"
1414
const elementResizeDetector = elementResizeDetectorImport({ strategy: "scroll" })
1515

16-
let overlayStyle
17-
18-
function ensureOverlayStyle() {
19-
if (!overlayStyle) {
20-
overlayStyle = document.createElement("style")
21-
overlayStyle.setAttribute("context", "atom-text-editor-minimap")
22-
document.head.appendChild(overlayStyle)
23-
}
24-
}
25-
26-
function removeOverlayStyle() {
27-
if (overlayStyle) {
28-
overlayStyle.parentNode.removeChild(overlayStyle)
29-
overlayStyle = null
30-
}
31-
}
32-
33-
function updateOverlayStyle(basis) {
34-
if (overlayStyle) {
35-
overlayStyle.textContent = `
36-
atom-text-editor[with-minimap].editor > div,
37-
atom-text-editor[with-minimap] > div {
38-
margin-left: ${basis}px;
39-
}
40-
`
41-
}
42-
}
43-
4416
const SPEC_MODE = atom.inSpecMode()
4517

4618
/**
@@ -118,10 +90,6 @@ class MinimapElement {
11890

11991
// Configs
12092

121-
/**
122-
* @access private
123-
*/
124-
this.displayMinimapOnLeft = false
12593
/**
12694
* @access private
12795
*/
@@ -224,7 +192,6 @@ class MinimapElement {
224192
atom.config.observe("minimap.displayMinimapOnLeft", (displayMinimapOnLeft) => {
225193
this.displayMinimapOnLeft = displayMinimapOnLeft
226194

227-
displayMinimapOnLeft ? ensureOverlayStyle() : removeOverlayStyle()
228195
this.updateMinimapFlexPosition()
229196
this.measureHeightAndWidth(true, true)
230197
}),
@@ -410,7 +377,7 @@ class MinimapElement {
410377
this.attachedToTextEditor = this.queryParentSelector("atom-text-editor") === this.minimap.getTextEditorElement()
411378

412379
if (this.attachedToTextEditor) {
413-
this.minimap.getTextEditorElement().setAttribute("with-minimap", "")
380+
this.minimap.getTextEditorElement().setAttribute("with-minimap", this.displayMinimapOnLeft ? "left" : "right")
414381
}
415382

416383
this.subscriptions.add(this.subscribeToMediaQuery())
@@ -494,6 +461,9 @@ class MinimapElement {
494461
*/
495462
updateMinimapFlexPosition() {
496463
this.classList.toggle("left", this.displayMinimapOnLeft)
464+
if (this.attachedToTextEditor) {
465+
this.minimap.getTextEditorElement().setAttribute("with-minimap", this.displayMinimapOnLeft ? "left" : "right")
466+
}
497467
}
498468

499469
/**
@@ -1086,13 +1056,10 @@ class MinimapElement {
10861056
) {
10871057
this.flexBasis = width
10881058
canvasWidth = width
1089-
updateOverlayStyle(width)
10901059
} else {
1091-
updateOverlayStyle(canvasWidth)
10921060
delete this.flexBasis
10931061
}
10941062
} else {
1095-
updateOverlayStyle(canvasWidth)
10961063
delete this.flexBasis
10971064
}
10981065

spec/minimap-element-spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,11 +1503,11 @@ describe("MinimapElement", () => {
15031503
expect(minimapElement.classList.contains("left")).toBeTruthy()
15041504
})
15051505

1506-
it("creates a style node with an offset for atom overlays", () => {
1506+
it("changes with-minimap attribute value to direction", () => {
15071507
atom.config.set("minimap.displayMinimapOnLeft", true)
1508-
1509-
const node = document.querySelector('style[context="atom-text-editor-minimap"]')
1510-
expect(node).toExist()
1508+
expect(editorElement.getAttribute("with-minimap")).toBe("left")
1509+
atom.config.set("minimap.displayMinimapOnLeft", false)
1510+
expect(editorElement.getAttribute("with-minimap")).toBe("right")
15111511
})
15121512

15131513
describe("and then toggled off", () => {

styles/minimap.less

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ atom-notifications:empty {
77
atom-text-editor[with-minimap] {
88
display: flex;
99

10-
.editor--private {
10+
> div {
1111
order: 2;
1212
flex: 1 0 90%;
1313
width: 90%;
@@ -31,26 +31,23 @@ html {
3131
cursor: default;
3232

3333
&:not([stand-alone]) {
34-
contain: @contain_all;
3534
height: 100%;
3635
order: 3;
3736
width: 10%;
3837
flex: 0 0 10%;
3938

4039
&.left {
41-
contain: @contain_all;
4240
order: 1;
43-
position: absolute;
4441
}
4542
}
4643

47-
&.absolute {
48-
contain: @contain_all;
44+
// ignore absolute mode the minimap is on the left, because
45+
// it would conflict with the editor's gutter
46+
&.absolute:not(.left) {
4947
position: absolute;
5048
right: 0;
5149

5250
&.adjust-absolute-height {
53-
contain: @contain_all;
5451
pointer-events: none;
5552

5653
canvas,
@@ -60,13 +57,6 @@ html {
6057
}
6158
}
6259

63-
// absolute mode do nothing when the minimap is on the left, because
64-
// it would conflict with the editor's gutter
65-
&.left {
66-
contain: @contain_all;
67-
right: initial;
68-
}
69-
7060
.open-minimap-quick-settings {
7161
contain: @contain_all;
7262
right: 16px;
@@ -90,7 +80,6 @@ html {
9080
border-left: 0px solid rgba(127, 127, 127, 0.1);
9181

9282
&:active {
93-
contain: @contain_all;
9483
cursor: -webkit-grabbing;
9584
}
9685

@@ -179,7 +168,6 @@ minimap-quick-settings {
179168
height: 1px;
180169

181170
&:first-child {
182-
contain: @contain_all;
183171
display: none;
184172
}
185173
}

0 commit comments

Comments
 (0)