Skip to content

Commit 1bb5a0b

Browse files
authored
Merge pull request #215 from rtfpessoa/fix-linenumbers-on-scroll
Fix linenumbers on scroll
2 parents cca1b34 + 4418f5f commit 1bb5a0b

File tree

3 files changed

+956
-1099
lines changed

3 files changed

+956
-1099
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@
5454
"fs": false
5555
},
5656
"dependencies": {
57-
"diff": "^3.5.0",
57+
"diff": "^4.0.1",
5858
"hogan.js": "^3.0.2",
5959
"lodash.merge": "^4.6.1",
6060
"whatwg-fetch": "^3.0.0"
6161
},
6262
"devDependencies": {
63-
"autoprefixer": "^9.3.1",
63+
"autoprefixer": "^9.5.1",
6464
"browserify": "^16.2.3",
65-
"clean-css-cli": "^4.2.1",
66-
"codacy-coverage": "^3.2.0",
67-
"eslint": "^5.9.0",
68-
"eslint-plugin-promise": "^4.0.1",
65+
"clean-css-cli": "^4.3.0",
66+
"codacy-coverage": "^3.4.0",
67+
"eslint": "^5.16.0",
68+
"eslint-plugin-promise": "^4.1.1",
6969
"eslint-plugin-standard": "^4.0.0",
7070
"fast-html-parser": "^1.0.1",
7171
"istanbul": "^0.4.5",
7272
"mkdirp": "^0.5.1",
73-
"mocha": "^5.2.0",
73+
"mocha": "5.2.0",
7474
"nopt": "^4.0.1",
75-
"postcss-cli": "^6.0.1",
76-
"uglify-js": "^3.4.9"
75+
"postcss-cli": "^6.1.2",
76+
"uglify-js": "^3.5.9"
7777
},
7878
"license": "MIT",
7979
"files": [

src/ui/css/diff2html.css

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,13 @@
7474
font-size: 13px;
7575
}
7676

77-
.d2h-diff-tbody > tr > td {
78-
height: 20px;
79-
line-height: 1;
80-
}
81-
8277
.d2h-files-diff {
8378
display: block;
8479
width: 100%;
8580
height: 100%;
8681
}
8782

8883
.d2h-file-diff {
89-
overflow-x: scroll;
9084
overflow-y: hidden;
9185
}
9286

@@ -102,13 +96,15 @@
10296
.d2h-code-line {
10397
display: inline-block;
10498
white-space: nowrap;
105-
padding: 0 10px;
99+
/* Compensate for the absolute positioning of the line numbers */
100+
padding: 0 8em;
106101
}
107102

108103
.d2h-code-side-line {
109104
display: inline-block;
110105
white-space: nowrap;
111-
padding: 0 10px;
106+
/* Compensate for the absolute positioning of the line numbers */
107+
padding: 0 4.5em;
112108
}
113109

114110
.d2h-code-line del,
@@ -149,26 +145,27 @@
149145
.line-num1 {
150146
box-sizing: border-box;
151147
float: left;
152-
width: 40px;
148+
width: 3.5em;
153149
overflow: hidden;
154150
text-overflow: ellipsis;
155-
padding-left: 3px;
151+
padding: 0 0.5em 0 0.5em;
156152
}
157153

158154
.line-num2 {
159155
box-sizing: border-box;
160156
float: right;
161-
width: 40px;
157+
width: 3.5em;
162158
overflow: hidden;
163159
text-overflow: ellipsis;
164-
padding-left: 3px;
160+
padding: 0 0.5em 0 0.5em;
165161
}
166162

167163
.d2h-code-linenumber {
168164
box-sizing: border-box;
169-
width: 86px;
170-
padding-left: 2px;
171-
padding-right: 2px;
165+
width: 7.5em;
166+
/* Keep the numbers fixed on line contents scroll */
167+
position: absolute;
168+
display: inline-block;
172169
background-color: #fff;
173170
color: rgba(0, 0, 0, 0.3);
174171
text-align: right;
@@ -177,11 +174,16 @@
177174
cursor: pointer;
178175
}
179176

177+
.d2h-code-linenumber:after {
178+
content: '\200b';
179+
}
180+
180181
.d2h-code-side-linenumber {
182+
/* Keep the numbers fixed on line contents scroll */
183+
position: absolute;
184+
display: inline-block;
181185
box-sizing: border-box;
182-
width: 56px;
183-
padding-left: 5px;
184-
padding-right: 5px;
186+
width: 4em;
185187
background-color: #fff;
186188
color: rgba(0, 0, 0, 0.3);
187189
text-align: right;
@@ -192,6 +194,10 @@
192194
text-overflow: ellipsis;
193195
}
194196

197+
.d2h-code-side-linenumber:after {
198+
content: '\200b';
199+
}
200+
195201
.d2h-code-side-emptyplaceholder,
196202
.d2h-emptyplaceholder {
197203
background-color: #f1f1f1;

0 commit comments

Comments
 (0)