File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
ui/arduino/views/components/elements Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,31 @@ class CodeMirrorEditor extends Component {
33 super ( )
44 this . editor = null
55 this . content = '# empty file'
6+ this . scrollTop = 0
67 }
78
89 load ( el ) {
910 const onCodeChange = ( update ) => {
10- // console.log('code change', this.content)
1111 this . content = update . state . doc . toString ( )
1212 this . onChange ( )
1313 }
1414 this . editor = createEditor ( this . content , el , onCodeChange )
15+ this . editor . scrollDOM . addEventListener ( 'scroll' , this . updateScrollPosition . bind ( this ) )
16+ setTimeout ( ( ) => {
17+ this . editor . scrollDOM . scrollTo ( {
18+ top : this . scrollTop ,
19+ left : 0
20+ } )
21+ } , 1 )
22+ }
23+
24+ updateScrollPosition ( e ) {
25+ console . log ( e . target . scrollTop )
26+ this . scrollTop = e . target . scrollTop
27+ }
28+
29+ unload ( ) {
30+ this . editor . scrollDOM . removeEventListener ( 'scroll' , this . updateScrollPosition )
1531 }
1632
1733 createElement ( content ) {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function Tab(args) {
5757 }
5858
5959 function selectTab ( e ) {
60- if ( e . target . tagName === 'BUTTON' || e . target . tagName === 'IMG' ) return
60+ if ( e . target . classList . contains ( 'close-tab' ) ) return
6161 onSelectTab ( e )
6262 }
6363
@@ -71,9 +71,9 @@ function Tab(args) {
7171 < div class ="text ">
7272 ${ hasChanges ? '*' : '' } ${ text }
7373 </ div >
74- < div class ="options ">
75- < button onclick =${ onCloseTab } >
76- < img class ="icon " src ="media/close.svg " />
74+ < div class ="options close-tab ">
75+ < button class =" close-tab " onclick =${ onCloseTab } >
76+ < img class ="close-tab icon " src ="media/close.svg " />
7777 </ button >
7878 </ div >
7979 </ div >
You can’t perform that action at this time.
0 commit comments