1
1
import { FinBar } from '../finbars/finbars' ;
2
2
import modules from './modules' ;
3
+ import { Hypergrid } from './types' ;
3
4
const Scrollbar = modules . Scrollbar ;
4
5
5
6
/**
@@ -35,14 +36,14 @@ exports.mixin = {
35
36
* @type {FinBar }
36
37
* @memberOf Hypergrid#
37
38
*/
38
- sbVScroller : null as FinBar | null ,
39
+ sbVScroller : null as FinBar | null ,
39
40
40
41
/**
41
42
* The horizontal scroll bar model/controller.
42
43
* @type {FinBar }
43
44
* @memberOf Hypergrid#
44
45
*/
45
- sbHScroller : null as FinBar | null ,
46
+ sbHScroller : null as FinBar | null ,
46
47
47
48
/**
48
49
* The previous value of sbVScrollVal.
@@ -61,7 +62,7 @@ exports.mixin = {
61
62
scrollingNow : false ,
62
63
63
64
/**
64
- * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672)
65
+ * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672}
65
66
* @memberOf Hypergrid#
66
67
* @summary Set for `scrollingNow` field.
67
68
* @param {boolean } isItNow - The type of event we are interested in.
@@ -161,7 +162,7 @@ exports.mixin = {
161
162
} ,
162
163
163
164
/**
164
- * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672)
165
+ * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672}
165
166
* @memberOf Hypergrid#
166
167
* @this {Hypergrid}
167
168
* @desc Set the vertical scroll value.
@@ -194,11 +195,11 @@ exports.mixin = {
194
195
} ,
195
196
196
197
/**
197
- * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672)
198
+ * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672}
198
199
* @memberOf Hypergrid#
199
200
* @this {Hypergrid}
200
201
* @desc Set the horizontal scroll value.
201
- * @param {number } newValue - The new scroll value.
202
+ * @param {number } x - The new scroll value.
202
203
*/
203
204
setHScrollValue : function ( x ) {
204
205
var self = this ;
@@ -228,7 +229,7 @@ exports.mixin = {
228
229
} ,
229
230
230
231
/**
231
- * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672)
232
+ * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672}
232
233
* @memberOf Hypergrid#
233
234
* @this {Hypergrid}
234
235
* @desc Initialize the scroll bars.
@@ -276,20 +277,28 @@ exports.mixin = {
276
277
this . resizeScrollbars ( ) ;
277
278
} ,
278
279
279
- resizeScrollbars : function ( ) {
280
+ resizeScrollbars ( this : Hypergrid ) {
281
+ // Cache the current visibility state of the scrollbars.
282
+ const hVisible = this . sbHScroller . isVisible ;
283
+ const vVisible = this . sbVScroller . isVisible ;
284
+
285
+ // Let the scrollbars resize themselves based on the content and container sizes.
280
286
this . sbHScroller . shortenBy ( this . sbVScroller ) . resize ( ) ;
281
287
this . sbVScroller
282
288
// NOTE: Below is commented out because it would show a square in the corner not covered by the scroll bar.
283
289
//.shortenBy(this.sbHScroller)
284
290
. resize ( ) ;
291
+
292
+ // If visibility changed during scrollbar resize, then the grid shape changed, and the canvas should resize.
293
+ if ( this . sbHScroller . isVisible !== hVisible || this . sbVScroller . isVisible !== vVisible ) {
294
+ this . canvas . resize ( ) ;
295
+ }
285
296
} ,
286
297
287
298
/**
288
- * @memberOf Hypergrid#
289
- * @this {Hypergrid}
290
- * @desc Scroll values have changed, we've been notified.
299
+ * Scroll values have changed, we've been notified.
291
300
*/
292
- setVScrollbarValues : function ( max , containerSize ) {
301
+ setVScrollbarValues ( this : Hypergrid , max : number , containerSize : number ) {
293
302
// Set the scroll range, which by default resets the contentSize.
294
303
this . sbVScroller . range = {
295
304
min : 0 ,
@@ -300,7 +309,7 @@ exports.mixin = {
300
309
this . sbVScroller . containerSize = containerSize ;
301
310
} ,
302
311
303
- setHScrollbarValues : function ( max , containerSize ) {
312
+ setHScrollbarValues ( this : Hypergrid , max : number , containerSize : number ) {
304
313
// Set the scroll range, which by default resets the contentSize.
305
314
this . sbHScroller . range = {
306
315
min : 0 ,
@@ -312,7 +321,7 @@ exports.mixin = {
312
321
} ,
313
322
314
323
/**
315
- * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672)
324
+ * @type {any } // Handle TS bug, remove this issue after resolved {@link https://github.com/microsoft/TypeScript/issues/41672}
316
325
* @this {Hypergrid}
317
326
*/
318
327
scrollValueChangedNotification : function ( ) {
@@ -337,7 +346,7 @@ exports.mixin = {
337
346
* @desc The data dimensions have changed, or our pixel boundaries have changed.
338
347
* Adjust the scrollbar properties as necessary.
339
348
*/
340
- synchronizeScrollingBoundaries : function ( ) {
349
+ synchronizeScrollingBoundaries ( ) {
341
350
var bounds = this . getBounds ( ) ;
342
351
if ( ! bounds ) {
343
352
return ;
@@ -346,7 +355,7 @@ exports.mixin = {
346
355
var numFixedColumns = this . getFixedColumnCount ( ) ,
347
356
numColumns = this . getColumnCount ( ) ,
348
357
numRows = this . getRowCount ( ) ,
349
- scrollableWidth = bounds . width - this . behavior . getFixedColumnsMaxWidth ( ) - this . sbHScroller . thickness ,
358
+ scrollableWidth = bounds . width - this . behavior . getFixedColumnsMaxWidth ( ) ,
350
359
gridProps = this . properties ,
351
360
borderBox = gridProps . boxSizing === 'border-box' ,
352
361
lineGap = borderBox ? 0 : gridProps . gridLinesVWidth ;
@@ -363,8 +372,8 @@ exports.mixin = {
363
372
}
364
373
365
374
// Note: Scrollable height excludes the header.
366
- var scrollableHeight = this . renderer . getVisibleScrollHeight ( ) - this . sbVScroller . thickness ;
367
- lineGap = borderBox ? 0 : gridProps . gridLinesHWidth ;
375
+ var scrollableHeight = this . renderer . getVisibleScrollHeight ( ) ;
376
+ lineGap = borderBox ? 0 : gridProps . gridLinesHWidth ; // NOTE: Excludes total row thickness.
368
377
369
378
for (
370
379
var rowsHeight = 0 , lastPageRowCount = 0 ;
0 commit comments