This repository was archived by the owner on Dec 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,15 @@ export default class StyleguideView {
1212 this . uri = props . uri
1313 this . collapsedSections = props . collapsedSections ? new Set ( props . collapsedSections ) : new Set ( )
1414 this . sections = [ ]
15+ this . mainSections = null
16+ this . keyCodeToScrollStep = {
17+ '33' : - 200 , // pageup
18+ '34' : 200 , // pagedown
19+ '38' : - 100 , // up
20+ '40' : 100 , // down
21+ '36' : Number . MIN_SAFE_INTEGER , // home
22+ '35' : Number . MAX_SAFE_INTEGER , // end
23+ }
1524 etch . initialize ( this )
1625 for ( const section of this . sections ) {
1726 if ( this . collapsedSections . has ( section . name ) ) {
@@ -24,6 +33,7 @@ export default class StyleguideView {
2433
2534 destroy ( ) {
2635 this . sections = null
36+ this . mainSections = null
2737 }
2838
2939 serialize ( ) {
@@ -62,6 +72,16 @@ export default class StyleguideView {
6272 }
6373 }
6474
75+ onKeyDownScroll ( keyCode ) {
76+ if ( ! this . keyCodeToScrollStep [ keyCode ] ) return
77+ if ( ! this . mainSections ) {
78+ this . mainSections = document . querySelector ( '.styleguide main.styleguide-sections' )
79+ }
80+ if ( this . mainSections ) {
81+ this . mainSections . scrollTop += this . keyCodeToScrollStep [ keyCode ]
82+ }
83+ }
84+
6585 render ( ) {
6686 return (
6787 < div className = 'styleguide pane-item native-key-bindings' tabIndex = '-1' >
Original file line number Diff line number Diff line change 11const { CompositeDisposable} = require ( 'atom' )
2+ const DOMListener = require ( 'dom-listener' )
23let StyleguideView = null
34
45const STYLEGUIDE_URI = 'atom://styleguide'
@@ -9,8 +10,14 @@ module.exports = {
910 this . subscriptions . add ( atom . workspace . addOpener ( filePath => {
1011 if ( filePath === STYLEGUIDE_URI ) return this . createStyleguideView ( { uri : STYLEGUIDE_URI } )
1112 } ) )
12- this . subscriptions . add ( atom . commands . add ( 'atom-workspace' , 'styleguide:show' , ( ) => atom . workspace . open ( STYLEGUIDE_URI ) )
13- )
13+ this . subscriptions . add ( atom . commands . add ( 'atom-workspace' , 'styleguide:show' ,
14+ ( ) => atom . workspace . open ( STYLEGUIDE_URI ) . then ( ( ) => {
15+ this . domListener = new DOMListener ( document . querySelector ( 'atom-workspace' ) )
16+ return this . domListener . add ( '.styleguide' , 'keydown' , event => {
17+ return this . styleguideView . onKeyDownScroll ( event . keyCode )
18+ } )
19+ } )
20+ ) )
1421 } ,
1522
1623 deactivate ( ) {
@@ -19,6 +26,6 @@ module.exports = {
1926
2027 createStyleguideView ( state ) {
2128 if ( StyleguideView == null ) StyleguideView = require ( './styleguide-view' )
22- return new StyleguideView ( state )
29+ return this . styleguideView = new StyleguideView ( state ) ;
2330 }
2431}
Original file line number Diff line number Diff line change 88 "dependencies" : {
99 "atom-select-list" : " ^0.7.0" ,
1010 "dedent" : " ^0.7.0" ,
11+ "dom-listener" : " ^0.1.2" ,
1112 "etch" : " 0.9.0" ,
1213 "highlights" : " ^3.1.1"
1314 },
You can’t perform that action at this time.
0 commit comments