@@ -1209,9 +1209,9 @@ Satus.components.main = function(object) {
12091209
12101210 return component ;
12111211} ;
1212- /*--------------------------------------------------------------
1212+ /*-----------------------------------------------------------------------------
12131213>>> SCROLL BAR
1214- --------------------------------------------------------------*/
1214+ ----------------------------------------------------------------------------- */
12151215
12161216Satus . components . scrollbar = function ( parent ) {
12171217 var component = document . createElement ( 'div' ) ,
@@ -1224,51 +1224,64 @@ Satus.components.scrollbar = function(parent) {
12241224 component_content . className = 'satus-scrollbar__content' ;
12251225 component_thumb . className = 'satus-scrollbar__thumb' ;
12261226
1227- window . addEventListener ( 'resize' , function ( event ) {
1227+
1228+ // RESIZE
1229+
1230+ function resize ( ) {
12281231 component_content . style . width = component . offsetWidth + 'px' ;
1232+ component_wrapper . style . height = component . offsetHeight + 'px' ;
1233+
1234+ if ( component_wrapper . scrollHeight > component_wrapper . offsetHeight ) {
1235+ component_thumb . style . height = component_wrapper . offsetHeight / component_wrapper . scrollHeight * component_wrapper . offsetHeight + 'px' ;
1236+ }
1237+ }
1238+
1239+ window . addEventListener ( 'resize' , resize ) ;
1240+
1241+ new MutationObserver ( resize ) . observe ( component_content , {
1242+ subtree : true ,
1243+ childList : true
12291244 } ) ;
12301245
1231- component . interval = false ;
1246+
1247+ // HOVER
1248+
1249+ component . timeout = false ;
12321250
12331251 function active ( ) {
1234- if ( component . interval ) {
1235- clearTimeout ( component . interval ) ;
1252+ if ( component . timeout ) {
1253+ clearTimeout ( component . timeout ) ;
12361254
1237- component . interval = false ;
1255+ component . timeout = false ;
12381256 }
12391257
12401258 component . classList . add ( 'active' ) ;
12411259
1242- component . interval = setTimeout ( function ( ) {
1260+ component . timeout = setTimeout ( function ( ) {
12431261 component . classList . remove ( 'active' ) ;
12441262
1245- component . interval = false ;
1263+ component . timeout = false ;
12461264 } , 1000 ) ;
12471265 }
12481266
12491267 component . addEventListener ( 'mousemove' , active ) ;
12501268
1269+
1270+ // SCROLL
1271+
12511272 component_wrapper . addEventListener ( 'scroll' , function ( event ) {
12521273 active ( ) ;
12531274
12541275 component_thumb . style . top = Math . floor ( component_wrapper . scrollTop * ( component_wrapper . offsetHeight - component_thumb . offsetHeight ) / ( component_wrapper . scrollHeight - component_wrapper . offsetHeight ) ) + 'px' ;
12551276 } ) ;
12561277
1257- new MutationObserver ( function ( ) {
1258- component_content . style . width = component . offsetWidth + 'px' ;
1259- component_wrapper . style . height = component . offsetHeight + 'px' ;
1260-
1261- if ( component_wrapper . scrollHeight > component_wrapper . offsetHeight ) {
1262- component_thumb . style . height = component_wrapper . offsetHeight / component_wrapper . scrollHeight * component_wrapper . offsetHeight + 'px' ;
1263- }
1264- } ) . observe ( component_content , {
1265- subtree : true ,
1266- childList : true
1267- } ) ;
1268-
12691278 component_thumb . addEventListener ( 'mousedown' , function ( event ) {
12701279 var offsetY = event . layerY ;
12711280
1281+ if ( event . button !== 0 ) {
1282+ return false ;
1283+ }
1284+
12721285 function mousemove ( event ) {
12731286 var offset = 100 / ( ( component . offsetHeight - component_thumb . offsetHeight ) / ( event . clientY - offsetY - component . getBoundingClientRect ( ) . top ) ) ,
12741287 scroll = component_wrapper . scrollHeight - component . offsetHeight ;
@@ -1862,6 +1875,7 @@ Satus.components.table = function(item) {
18621875 var table = document . createElement ( 'div' ) ,
18631876 table_head = document . createElement ( 'div' ) ,
18641877 table_body = document . createElement ( 'div' ) ,
1878+ component_scrollbar = Satus . components . scrollbar ( table_body ) ,
18651879 table_rows = [ ] ;
18661880
18671881 table_head . className = 'satus-table__head' ;
@@ -1939,13 +1953,13 @@ Satus.components.table = function(item) {
19391953 table . update ( sorted_rows ) ;
19401954 } ;
19411955
1942- Satus . render ( col , item . columns [ i ] ) ;
1956+ Satus . render ( item . columns [ i ] , col ) ;
19431957
19441958 table_head . appendChild ( col ) ;
19451959 }
19461960
19471961 function update ( rows ) {
1948- this . querySelector ( '.satus-table__body' ) . innerHTML = '' ;
1962+ component_scrollbar . innerHTML = '' ;
19491963
19501964 table_rows = rows ;
19511965
@@ -1962,7 +1976,7 @@ Satus.components.table = function(item) {
19621976 row . appendChild ( col ) ;
19631977 }
19641978
1965- this . querySelector ( '.satus-table__body' ) . appendChild ( row ) ;
1979+ component_scrollbar . appendChild ( row ) ;
19661980 }
19671981 }
19681982
0 commit comments