dynamic-virtual-scroller
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "dynamic-virtual-scroller", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A virtual scroller for the web that can handle dynamic row and column sizes.", | ||
@@ -5,0 +5,0 @@ "main": "virtual-scroller.js", |
@@ -1419,4 +1419,69 @@ window.VirtualScroller = (function ($, _) { | ||
/* | ||
Dom Cache Adapter | ||
*/ | ||
VirtualScroller.DomCacheAdapter = function (scrollerConfig) { | ||
/* | ||
TODO: React to all dynamic changes like rowRemoved, rowAdded, rerender, ... | ||
*/ | ||
var rowCache = {}; | ||
var columnCache = {}; | ||
var oldOnBeforeRowRemoved = scrollerConfig.onBeforeRowRemoved; | ||
scrollerConfig.onBeforeRowRemoved = function (params) { | ||
if (oldOnBeforeRowRemoved) { | ||
oldOnBeforeRowRemoved(params); | ||
} | ||
rowCache[params.rowIndex] = params.row; | ||
params.row.detach(); | ||
params.row.find('[virtual-scroller-index]').each(function (index, column) { | ||
column = $(column); | ||
var columnIndex = parseInt(column.attr('virtual-scroller-index')); | ||
columnCache[params.rowIndex] = columnCache[params.rowIndex] || {}; | ||
columnCache[params.rowIndex][columnIndex] = column; | ||
}); | ||
return false; | ||
}; | ||
var oldRenderRow = scrollerConfig.renderRow; | ||
scrollerConfig.renderRow = function (params) { | ||
if (rowCache[params.rowIndex]) { | ||
console.log('got it from cache'); | ||
return rowCache[params.rowIndex]; | ||
} | ||
return oldRenderRow(params); | ||
}; | ||
if (scrollerConfig.renderColumn) { | ||
var oldOnBeforeColumnRemoved = scrollerConfig.onBeforeColumnRemoved; | ||
scrollerConfig.onBeforeColumnRemoved = function (params) { | ||
if (oldOnBeforeRowRemoved) { | ||
oldOnBeforeRowRemoved(params); | ||
} | ||
columnCache[params.rowIndex] = columnCache[params.rowIndex] || {}; | ||
columnCache[params.rowIndex][params.columnIndex] = params.column; | ||
params.column.detach(); | ||
return false; | ||
}; | ||
var oldRenderColumn = scrollerConfig.renderColumn; | ||
scrollerConfig.renderColumn = function (params) { | ||
if (columnCache[params.rowIndex][params.columnIndex]) { | ||
console.log('got it from cache'); | ||
return columnCache[params.rowIndex][params.columnIndex]; | ||
} | ||
return oldRenderColumn(params); | ||
}; | ||
} | ||
return scrollerConfig; | ||
}; | ||
return VirtualScroller; | ||
}(jQuery, _)); |
Sorry, the diff of this file is not supported yet
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
244344
1866