public setDir()

in packages/attribute-slicer/src/lib/VirtualList.ts [200:244]


	public setDir(horiz: boolean): void {
		const size: number = this.itemHeight * this.totalRows;
		const height: number = this.getContainerHeight();
		const width: number = this.getContainerWidth();
		this.horiz = horiz;
		if (horiz) {
			this.scrollProp = "scrollLeft";
			this.scroller.style("width", `${size}px`).style("height", "1px");
			this.listContainer
				.style("transform", `rotate(-90deg) translateX(-${height - 5}px)`)
				.style("transform-origin", "0px 0px")
				.style("height", `${width}px`)
				.style("width", `${height}px`);
			this.container
				.style("overflow-x", "auto")
				.style("overflow-y", "hidden")
				.node().scrollTop = 0;
		} else {
			this.scrollProp = "scrollTop";
			this.scroller.style("width", "1px").style("height", `${size}px`);
			this.listContainer
				.style("transform", null)
				.style("transform-origin", null)
				.style("width", `${width}px`)
				.style("height", `${height}px`);
			this.container
				.style("overflow-x", "hidden")
				.style("overflow-y", "auto")
				.node().scrollLeft = 0;
		}

		const screenItemsLen: number = (this.screenItemsLen = Math.ceil(
			(this.horiz ? width : height) / this.itemHeight,
		));
		// Cache 4 times the number of items that fit in the container viewport
		this.cachedItemsLen = screenItemsLen * 3;
		this.maxBuffer = screenItemsLen * this.itemHeight;
		this.lastRepaintPos = undefined;
		if (this.items) {
			const first: number =
				Math.floor(this.container.node()[this.scrollProp] / this.itemHeight) -
				this.screenItemsLen;
			this.renderChunkDebounced(this.listContainer, first < 0 ? 0 : first);
		}
	}