public itemHovered()

in packages/attribute-slicer/src/selection/SelectionManager.ts [154:198]


	public itemHovered(item: T): IBrushSelectionDelta<T> {
		const delta: IBrushSelectionDelta<T> = { added: [], removed: [] };
		if (this.internalDragging && this.internalBrushMode) {
			if (
				this.internalBrushingSelection.length >= 1 &&
				this.items &&
				this.items.length
			) {
				let lowIndex: number;
				let highIndex: number;
				const newSel: T[] = this.internalBrushingSelection.slice(0);

				if (this.findIndex(item, newSel) > -1) {
					// remove item if dragging back
					newSel.splice(newSel.indexOf(this.internalPreviousBrushedItem), 1);
					delta.removed.push(this.internalPreviousBrushedItem);
				} else {
					// add the item to selection list
					newSel.push(item);
					delta.added.push(item);
				}

				newSel.forEach((n: T) => {
					const currIndex: number = this.internalItems.indexOf(n);
					if (lowIndex === undefined || currIndex < lowIndex) {
						lowIndex = currIndex;
					}
					if (highIndex === undefined || currIndex > highIndex) {
						highIndex = currIndex;
					}
				});

				this.internalBrushingSelection = this.items.slice(
					lowIndex,
					highIndex + 1,
				);
			} else if (this.findIndex(item, this.internalBrushingSelection) < 0) {
				this.internalBrushingSelection.push(item);
				delta.added.push(item);
			}
			this.internalPreviousBrushedItem = item;
		}

		return delta;
	}