File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed
Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ function App(el, currentWindow) {
7474 this . router = new Router ( this )
7575 this . url = '/'
7676
77+ this . _shouldAutoScroll = true
78+
7779 this . _addRoutes ( )
7880 this . _addStyles ( )
7981 this . _addHandlers ( )
@@ -96,7 +98,7 @@ function App(el, currentWindow) {
9698 rootNode = patch ( rootNode , patches )
9799 tree = newTree
98100
99- if ( this . activeModel ) {
101+ if ( this . activeModel && this . _shouldAutoScroll ) {
100102 if ( this . activeModel . ele ) {
101103 const ele = document . querySelector ( this . activeModel . ele )
102104 if ( ele ) {
@@ -311,6 +313,17 @@ App.prototype._addHandlers = function _addHandlers() {
311313 return false
312314 } )
313315
316+ this . on ( 'scroll' , ( e ) => {
317+ const node = e . target
318+ if ( node . scrollHeight <= node . clientHeight + node . scrollTop ) {
319+ this . _shouldAutoScroll = true
320+ debug ( 'should auto scroll' )
321+ } else {
322+ debug ( 'should not auto scroll' )
323+ this . _shouldAutoScroll = false
324+ }
325+ } )
326+
314327 const addConnTooltip = new Tooltip ( this . el , {
315328 selector : 'a.add-connection'
316329 , placement : 'right'
Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ Channel.prototype.render = function render(channel) {
5858 ] )
5959 , h ( `.channel-container.${ ubcl } ` , {
6060 className : cl
61+ , onscroll : ( e ) => {
62+ this . target . emit ( 'scroll' , e )
63+ }
6164 } , kids )
6265 ]
6366}
Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ Connection.prototype.render = function render(conn) {
3838 , h ( 'p.subtitle' , `${ conn . server . host } :${ conn . server . port } ` )
3939 ] )
4040 ] )
41- , h ( '.logs-container' , [
41+ , h ( '.logs-container' , {
42+ onscroll : ( e ) => {
43+ this . target . emit ( 'scroll' , e )
44+ }
45+ } , [
4246 h ( 'ul.logs' , conn . logs . map ( ( log ) => {
4347 return this . log . render ( log )
4448 } ) )
Original file line number Diff line number Diff line change @@ -75,9 +75,7 @@ test('ChannelView', (t) => {
7575
7676 const container = out [ 1 ]
7777 t . equal ( container . tagName , 'DIV' )
78- t . deepEqual ( container . properties , {
79- className : 'channel-container userbar-shown'
80- } )
78+ t . equal ( container . properties . className , 'channel-container userbar-shown' )
8179
8280 t . equal ( container . children . length , 2 )
8381 t . equal ( container . children [ 0 ] . tagName , 'UL' )
You can’t perform that action at this time.
0 commit comments