File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
ui/arduino/views/components/elements Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -6,37 +6,39 @@ class CodeMirrorEditor extends Component {
66 this . scrollTop = 0
77 }
88
9+ createElement ( content ) {
10+ if ( content ) this . content = content
11+ return html `< div id ="code-editor "> </ div > `
12+ }
13+
14+
915 load ( el ) {
1016 const onCodeChange = ( update ) => {
1117 this . content = update . state . doc . toString ( )
1218 this . onChange ( )
1319 }
1420 this . editor = createEditor ( this . content , el , onCodeChange )
15- this . editor . scrollDOM . addEventListener ( 'scroll' , this . updateScrollPosition . bind ( this ) )
21+
1622 setTimeout ( ( ) => {
23+ this . editor . scrollDOM . addEventListener ( 'scroll' , this . updateScrollPosition . bind ( this ) )
1724 this . editor . scrollDOM . scrollTo ( {
1825 top : this . scrollTop ,
1926 left : 0
2027 } )
21- } , 1 )
28+ } , 10 )
2229 }
2330
24- updateScrollPosition ( e ) {
25- console . log ( e . target . scrollTop )
26- this . scrollTop = e . target . scrollTop
31+ update ( ) {
32+ return false
2733 }
2834
2935 unload ( ) {
3036 this . editor . scrollDOM . removeEventListener ( 'scroll' , this . updateScrollPosition )
3137 }
3238
33- createElement ( content ) {
34- if ( content ) this . content = content
35- return html `< div id ="code-editor "> </ div > `
36- }
37-
38- update ( ) {
39- return false
39+ updateScrollPosition ( e ) {
40+ console . log ( e . target . scrollTop )
41+ this . scrollTop = e . target . scrollTop
4042 }
4143
4244 onChange ( ) {
You can’t perform that action at this time.
0 commit comments