@syncfusion/ej2-lists 26.2.5 → 26.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1303,6 +1303,7 @@ let ListView = class ListView extends Component {
1303
1303
  }
1304
1304
  break;
1305
1305
  case 'dataSource':
1306
+ this.previousScrollTop = this.element.scrollTop;
1306
1307
  if (this.enableVirtualization) {
1307
1308
  this.virtualizationModule.reRenderUiVirtualization();
1308
1309
  }
@@ -2033,8 +2034,9 @@ let ListView = class ListView extends Component {
2033
2034
  if (!isNullOrUndefined(this.scroll)) {
2034
2035
  EventHandler.remove(this.element, 'scroll', this.onListScroll);
2035
2036
  }
2036
- if (this.touchModule)
2037
+ if (this.touchModule) {
2037
2038
  this.touchModule.destroy();
2039
+ }
2038
2040
  this.touchModule = null;
2039
2041
  }
2040
2042
  removeFocus() {
@@ -3182,8 +3184,10 @@ class Virtualization {
3182
3184
  */
3183
3185
  uiVirtualization() {
3184
3186
  this.wireScrollEvent(false);
3187
+ const isRendered = this.listViewInstance.isRendered;
3188
+ const firstIndex = isRendered && !isNullOrUndefined(this.uiFirstIndex) ? this.uiFirstIndex : 0;
3185
3189
  const curViewDS = this.listViewInstance.curViewDS;
3186
- const firstDs = curViewDS.slice(0, 1);
3190
+ const firstDs = curViewDS.slice(firstIndex, firstIndex + 1);
3187
3191
  this.listViewInstance.ulElement = this.listViewInstance.curUL = ListBase.createList(this.listViewInstance.createElement, firstDs, this.listViewInstance.listBaseOption, null, this.listViewInstance);
3188
3192
  this.listViewInstance.contentContainer = this.listViewInstance.createElement('div', { className: classNames.container });
3189
3193
  this.listViewInstance.element.appendChild(this.listViewInstance.contentContainer);
@@ -3191,9 +3195,10 @@ class Virtualization {
3191
3195
  this.listItemHeight = this.listViewInstance.ulElement.firstElementChild.getBoundingClientRect().height;
3192
3196
  this.expectedDomItemCount = this.ValidateItemCount(10000);
3193
3197
  this.domItemCount = this.ValidateItemCount(Object.keys(this.listViewInstance.curViewDS).length);
3194
- this.uiFirstIndex = 0;
3195
- this.uiLastIndex = this.domItemCount - 1;
3196
- const otherDs = curViewDS.slice(1, this.domItemCount);
3198
+ const lastIndex = isRendered && !isNullOrUndefined(this.uiLastIndex) ? this.uiLastIndex : this.domItemCount - 1;
3199
+ this.uiFirstIndex = firstIndex;
3200
+ this.uiLastIndex = lastIndex;
3201
+ const otherDs = curViewDS.slice(firstIndex + 1, lastIndex + 1);
3197
3202
  const listItems = ListBase.createListItemFromJson(this.listViewInstance.createElement, otherDs, this.listViewInstance.listBaseOption, null, null, this.listViewInstance);
3198
3203
  append(listItems, this.listViewInstance.ulElement);
3199
3204
  this.listViewInstance.liCollection = this.listViewInstance.curUL.querySelectorAll('li');
@@ -3202,11 +3207,14 @@ class Virtualization {
3202
3207
  this.bottomElement = this.listViewInstance.createElement('div');
3203
3208
  this.listViewInstance.ulElement.insertBefore(this.bottomElement, null);
3204
3209
  this.totalHeight = (Object.keys(curViewDS).length * this.listItemHeight) - (this.domItemCount * this.listItemHeight);
3205
- this.topElement.style.height = 0 + 'px';
3206
- this.bottomElement.style.height = this.totalHeight + 'px';
3207
- this.topElementHeight = 0;
3208
- this.bottomElementHeight = this.totalHeight;
3209
- this.listDiff = 0;
3210
+ this.topElement.style.height = isRendered ? this.topElementHeight + 'px' : '0px';
3211
+ this.bottomElement.style.height = isRendered ? (this.totalHeight - this.topElementHeight) + 'px' : this.totalHeight + 'px';
3212
+ this.topElementHeight = isRendered ? this.topElementHeight : 0;
3213
+ this.bottomElementHeight = isRendered ? (this.totalHeight - this.topElementHeight) : this.totalHeight;
3214
+ this.listDiff = isRendered ? this.listDiff : 0;
3215
+ if (isRendered) {
3216
+ this.listViewInstance.element.scrollTop = this.listViewInstance.previousScrollTop;
3217
+ }
3210
3218
  this.uiIndicesInitialization();
3211
3219
  }
3212
3220
  wireScrollEvent(destroy) {