File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ The HTML output accepts a Javascript object with configuration. Possible options
70
70
- ` outputFormat ` : the format of the output data: ` 'line-by-line' ` or ` 'side-by-side' ` , default is ` 'line-by-line' `
71
71
- ` showFiles ` : show a file list before the diff: ` true ` or ` false ` , default is ` false `
72
72
- ` matching ` : matching level: ` 'lines' ` for matching lines, ` 'words' ` for matching lines and words or ` 'none' ` , default is ` none `
73
+ - ` synchronisedScroll ` : scroll both panes in side-by-side mode: ` true ` or ` false ` , default is ` false `
73
74
- ` matchWordsThreshold ` : similarity threshold for word matching, default is 0.25
74
75
- ` matchingMaxComparisons ` : perform at most this much comparisons for line matching a block of changes, default is ` 2500 `
75
76
Original file line number Diff line number Diff line change 28
28
"url" : " git://github.com/rtfpessoa/diff2html.git"
29
29
},
30
30
"main" : [
31
- " ./dist/diff2html-templates.js" ,
32
31
" ./dist/diff2html.js" ,
33
- " ./dist/diff2html-ui.js" ,
34
32
" ./dist/diff2html.css"
35
33
],
36
34
"license" : " MIT" ,
Original file line number Diff line number Diff line change 267
267
inputFormat : 'json' ,
268
268
showFiles : true ,
269
269
matching : 'lines' ,
270
- outputFormat : 'side-by-side'
270
+ outputFormat : 'side-by-side' ,
271
+ synchronisedScroll : true
271
272
} ) ;
272
273
diff2htmlUi . fileListCloseable ( '#side-by-side' , false ) ;
273
274
diff2htmlUi . highlightCode ( '#side-by-side' ) ;
Original file line number Diff line number Diff line change 34
34
var cfg = config || { } ;
35
35
var $target = this . _getTarget ( targetId ) ;
36
36
$target . html ( Diff2Html . getPrettyHtml ( diffJson , cfg ) ) ;
37
+
38
+ synchronisedScroll ( $target , config ) ;
37
39
} ;
38
40
41
+ function synchronisedScroll ( $target , config ) {
42
+ if ( config . synchronisedScroll ) {
43
+
44
+ $target . find ( ".d2h-file-side-diff" ) . scroll ( function ( ) {
45
+ var $this = $ ( this ) ;
46
+ $this . closest ( ".d2h-file-wrapper" ) . find ( ".d2h-file-side-diff" )
47
+ . scrollLeft ( $this . scrollLeft ( ) ) ;
48
+ } ) ;
49
+
50
+ }
51
+ }
52
+
39
53
Diff2HtmlUI . prototype . fileListCloseable = function ( targetId , startVisible ) {
40
54
var $target = this . _getTarget ( targetId ) ;
41
55
You can’t perform that action at this time.
0 commit comments