public scrollItemIntoView()

in tutorials/viewer/src/tutorial_view.tsx [96:108]


    public scrollItemIntoView(index: number) {
        let item = this.captionMap[index];
        let yOffset = this.captions.getBoundingClientRect().top;
        let height = this.captions.getBoundingClientRect().height;
        let scrollTop = this.captions.scrollTop;
        let { y1, y, y2 } = item.getAnchorPoint();
        if (y1 < yOffset) {
            this.captions.scrollTop = Math.round(scrollTop + y1 - yOffset - height * 0.2);
        }
        if (y2 > yOffset + height) {
            this.captions.scrollTop = Math.round(scrollTop + y2 - yOffset + height * 0.8);
        }
    }