dynamic-virtual-scroller
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "dynamic-virtual-scroller", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A virtual scroller for the web that can handle dynamic row and column sizes.", | ||
@@ -5,0 +5,0 @@ "main": "virtual-scroller.js", |
@@ -740,2 +740,21 @@ window.VirtualScroller = (function ($, _) { | ||
renderManager.isRowRendered = function (params) { | ||
params = validateParameters(params, { | ||
rowIndex: {type: 'number'} | ||
}); | ||
return !!renderManager.state.children[params.rowIndex]; | ||
}; | ||
renderManager.isColumnRendered = function (params) { | ||
params = validateParameters(params, { | ||
rowIndex: {type: 'number', default: _.findIndex(renderManager.rowStates, function (state) { | ||
return !!state; | ||
})}, | ||
columnIndex: {type: 'number'} | ||
}); | ||
var rowState = renderManager.rowStates[params.rowIndex]; | ||
return !!rowState.children[params.columnIndex]; | ||
}; | ||
renderManager.reevaluateRowSizeAtIndex = function (params) { | ||
@@ -1332,3 +1351,8 @@ | ||
.css('height', ''); | ||
} | ||
}, | ||
isRowRendered: renderManager.isRowRendered, | ||
isColumnRendered: renderManager.isColumnRendered, | ||
}; | ||
@@ -1423,66 +1447,62 @@ | ||
Dom Cache Adapter | ||
TODO: React to all dynamic changes like rowRemoved, rowAdded, rerender, ... | ||
*/ | ||
VirtualScroller.DomCacheAdapter = function (scrollerConfig) { | ||
// VirtualScroller.DomCacheAdapter = function (scrollerConfig) { | ||
// | ||
// 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]) { | ||
// 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] && columnCache[params.rowIndex][params.columnIndex]) { | ||
// return columnCache[params.rowIndex][params.columnIndex]; | ||
// } | ||
// return oldRenderColumn(params); | ||
// }; | ||
// } | ||
// | ||
// | ||
// return 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] && columnCache[params.rowIndex][params.columnIndex]) { | ||
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
245169
1888