dynamic-virtual-scroller
Advanced tools
Comparing version 3.0.17 to 3.0.18
{ | ||
"name": "dynamic-virtual-scroller", | ||
"version": "3.0.17", | ||
"version": "3.0.18", | ||
"description": "A virtual scroller for the web that can handle dynamic row and column sizes.", | ||
@@ -5,0 +5,0 @@ "main": "virtual-scroller.js", |
@@ -155,2 +155,7 @@ import {ATTRIBUTES, EVENTS, CLASSES, DATA} from "./constants"; | ||
config.container.addClass([CLASSES.container, CLASSES.nativeScrolling].join(' ')); | ||
// The nativeScrollSizer is used tell the browser how big the scrollable area should be | ||
config.nativeScrollSizer = divProto | ||
.clone() | ||
.attr(ATTRIBUTES.createdByScroller, config.scrollerId) | ||
.appendTo(config.container); | ||
} else { | ||
@@ -213,16 +218,7 @@ config.container.addClass(CLASSES.container); | ||
/* | ||
Instead of using native scrolling, we calculate the scrollTop/scrollLeft values ourselves. | ||
That way, we can have total control. For example sticky rows would flicker if the main part of the scroller | ||
would be using native scrolling while only the sticky rows/columns are moved via css translate3d. | ||
*/ | ||
var lastScrollTop = 0; | ||
var lastScrollLeft = 0; | ||
var scrollManager = ScrollManager(config, renderManager); | ||
scrollManager.subscribe(_.throttle( | ||
(scrollLeft, scrollTop) => { | ||
// renderManager might have already been set to null in API.destroy | ||
if (!renderManager) { | ||
return; | ||
} | ||
if (config.useNativeScrolling) { | ||
var lastScrollTop = 0; | ||
var lastScrollLeft = 0; | ||
scrollManager.subscribe(function (scrollLeft, scrollTop) { | ||
/* | ||
@@ -240,7 +236,22 @@ Optimization: Only render if the scroll delta is bigger than a row / column. | ||
lastScrollLeft = scrollLeft; | ||
renderManager.render(scrollManager) | ||
}, | ||
Math.round(1000 / config.fps), | ||
{leading: true, trailing: true} | ||
)); | ||
renderManager.render(scrollManager); | ||
}); | ||
} else { | ||
/* | ||
Instead of using native scrolling, we calculate the scrollTop/scrollLeft values ourselves. | ||
That way, we can have total control. For example sticky rows would flicker if the main part of the scroller | ||
would be using native scrolling while only the sticky rows/columns are moved via css translate3d. | ||
*/ | ||
scrollManager.subscribe(_.throttle( | ||
(scrollLeft, scrollTop) => { | ||
// renderManager might have already been set to null in API.destroy | ||
if (!renderManager) { | ||
return; | ||
} | ||
renderManager.render(scrollManager) | ||
}, | ||
Math.round(1000 / config.fps), | ||
{leading: true, trailing: true} | ||
)); | ||
} | ||
@@ -295,40 +306,40 @@ | ||
if (_.every(params, _.isUndefined)) { | ||
return throttledResizeHandler(); // reevaluates all sizes | ||
} | ||
renderManager.reevaluateAllSizes(); | ||
} else { | ||
/* | ||
For static sizes | ||
*/ | ||
/* | ||
For static sizes | ||
*/ | ||
if (params.rowHeight !== undefined) { | ||
config.rowHeight = params.rowHeight; | ||
} | ||
if (params.rowHeight !== undefined) { | ||
config.rowHeight = params.rowHeight; | ||
} | ||
if (params.columnWidth !== undefined) { | ||
config.columnWidth = params.columnWidth; | ||
} | ||
if (params.columnWidth !== undefined) { | ||
config.columnWidth = params.columnWidth; | ||
} | ||
/* | ||
For dynamic sizes | ||
*/ | ||
/* | ||
For dynamic sizes | ||
*/ | ||
if (params.rowIndex !== undefined && params.columnIndex === undefined) { | ||
if (!config.dynamicRowHeight) { | ||
throw new Error('Virtual Scroller: You can\'t update the height of specific rows in static mode. Please set dynamicRowHeight to true in order to do that. Or pass rowHeight if the height of all rows changed.'); | ||
if (params.rowIndex !== undefined && params.columnIndex === undefined) { | ||
if (!config.dynamicRowHeight) { | ||
throw new Error('Virtual Scroller: You can\'t update the height of specific rows in static mode. Please set dynamicRowHeight to true in order to do that. Or pass rowHeight if the height of all rows changed.'); | ||
} | ||
renderManager.reevaluateRowSizeAtIndex({ | ||
rowIndex: params.rowIndex | ||
}); | ||
} | ||
renderManager.reevaluateRowSizeAtIndex({ | ||
rowIndex: params.rowIndex | ||
}); | ||
} | ||
if (params.columnIndex !== undefined) { | ||
if (!config.dynamicColumnWidth) { | ||
throw new Error('Virtual Scroller: You can\'t update the height of specific columns in static mode. Please set dynamicColumnWidth to true in order to do that. Or pass columnWidth if the width of all columns changed.'); | ||
if (params.columnIndex !== undefined) { | ||
if (!config.dynamicColumnWidth) { | ||
throw new Error('Virtual Scroller: You can\'t update the height of specific columns in static mode. Please set dynamicColumnWidth to true in order to do that. Or pass columnWidth if the width of all columns changed.'); | ||
} | ||
renderManager.reevaluateColumnSizeAtIndex({ | ||
rowIndex: params.rowIndex, // might be undefined | ||
columnIndex: params.columnIndex | ||
}); | ||
} | ||
renderManager.reevaluateColumnSizeAtIndex({ | ||
rowIndex: params.rowIndex, // might be undefined | ||
columnIndex: params.columnIndex | ||
}); | ||
} | ||
@@ -335,0 +346,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
530906
7415