in src/FacetsVisual.ts [440:491]
private bindFacetsEventHandlers() {
// If the mouse leaves the container while dragging, cancel it by triggering a mouseup event.
this.facetsContainer.on('mouseleave', (evt) => this.facetsContainer.trigger('mouseup'));
this.searchBox.on('input', debounce((e: any) => this.filterFacets(), 500));
this.facets.on('facet:click', (e: any, key: string, value: string) => this.toggleFacetSelection(key, value));
this.facets.on('facet-group:more', (e: any, key: string, index: number) =>
e.currentTarget.classList.contains('more') ? this.showMoreFacetInstances(key) : this.shrinkFacetGroup(key));
this.facets.on('facet-group:collapse', (e: any, key: string) => {
const facetGroup = this.getFacetGroup(key);
const selectedInstances = this.getSelectedInstances();
if (facetGroup.isRange) {
this.filter.range && this.filter.range[key] && (this.filter.range[key] = undefined);
this.filterFacets(true);
this.applySelection(selectedInstances);
this.facets._getGroup(key).collapsed = true;
} else {
const deselected = remove(selectedInstances, (selected) => selected.facetKey === key);
this.applySelection(selectedInstances);
this.updateFacetsSelection(selectedInstances);
}
facetGroup.collapsed = true;
this.saveFacetState();
});
this.facets.on('facet-group:expand', (e: any, key: string) => {
this.runWithNoAnimation(this.resetGroup, this, key);
this.facets._getGroup(key).collapsed = false;
this.getFacetGroup(key).collapsed = false;
this.saveFacetState();
});
this.facets.on('facet-group:dragging:end', () => {
// Save the order of the facets
this.data.facetsData.forEach((facetGroupData) => {
const group = this.facets._getGroup(facetGroupData.key);
facetGroupData.order = group.index;
});
this.saveFacetState();
});
this.facets.on('facet-histogram:rangechangeduser', (e: any, key: string, range: FacetRangeObject) => {
const isFullRange = range.from.metadata[0].isFirst && range.to.metadata[range.to.metadata.length - 1].isLast;
!this.filter.range && (this.filter.range = {});
this.filter.range[key] = isFullRange ? undefined : range;
this.data.hasHighlight ? (this.retainFilters = true) : this.filterFacets(true);
this.applySelection(this.getSelectedInstances());
});
}