in src/VisualMain.ts [190:282]
public update(options: VisualUpdateOptions) {
if (options["resizeMode"]) {
debounce(() => {
const shouldInline = this.isInlineSize(options.viewport);
if (shouldInline !== this.isInline) {
this.changeWrapMode(options.viewport);
}
this.cards.resize();
}, 200)();
return;
}
if (!options.dataViews || !(options.dataViews.length > 0)) {
return;
}
if (!utils.hasColumns(options.dataViews[0], constants.REQUIRED_FIELDS)) {
return;
}
this.dataView = options.dataViews[0];
const newObjects =
this.dataView && this.dataView.metadata && this.dataView.metadata.objects;
// const wasFiltering = this.settings.presentation.filter;
this.settings = $.extend(
true,
{},
constants.DEFAULT_VISUAL_SETTINGS,
newObjects
);
let previousLoadedDocumentCount = 0;
if (options.operationKind === VisualDataChangeOperationKind.Append) {
previousLoadedDocumentCount = this.loadedDocumentCount;
}
this.loadedDocumentCount = this.dataView
? countDocuments(this.dataView)
: 0;
this.hasMoreData = !!this.dataView.metadata.segment;
this.isLoadingMore =
this.settings.loadMoreData.show &&
this.loadMoreData &&
this.loadedDocumentCount < this.settings.loadMoreData.limit &&
this.hasMoreData;
if (this.isLoadingMore) {
// need to load more data
this.isLoadingMore = true;
this.showLoader();
this.loadMoreData();
return;
}
this.documentData = convertToDocumentData(
this.dataView,
this.settings,
options["dataTransforms"] && options["dataTransforms"].roles,
this.host
);
if (!previousLoadedDocumentCount) {
this.isFlipped =
this.settings.flipState.cardFaceDefault ===
constants.CARD_FACE_METADATA;
}
this.updateVisualStyleConfigs();
// if (wasFiltering && !this.settings.presentation.filter) {
// // clear any current filter
// this.selectionManager.clear();
// }
this.hideLoader();
if (previousLoadedDocumentCount) {
this.cards.loadMoreData(
this.documentData.documentList.slice(previousLoadedDocumentCount)
);
if (
this.isFlipped !==
(this.settings.flipState.cardFaceDefault ===
constants.CARD_FACE_METADATA)
) {
for (
let i = previousLoadedDocumentCount;
i < this.loadedDocumentCount;
i++
) {
this.cards.cardInstances[i].flip(this.isFlipped);
}
}
} else {
this.updateCards(options.viewport);
}
}