How to use the @ptsecurity/mosaic/core.countGroupLabelsBeforeOption function in @ptsecurity/mosaic

To help you get started, we’ve selected a few @ptsecurity/mosaic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github positive-js / mosaic / src / lib / select / select.component.ts View on Github external
private calculateOverlayPosition(): void {
        const itemHeight = this.getItemHeight();
        const items = this.getItemCount();
        const panelHeight = Math.min(items * itemHeight, SELECT_PANEL_MAX_HEIGHT);
        const scrollContainerHeight = items * itemHeight;

        // The farthest the panel can be scrolled before it hits the bottom
        const maxScroll = scrollContainerHeight - panelHeight;

        // If no value is selected we open the popup to the first item.
        let selectedOptionOffset =
            this.empty ? 0 : this.getOptionIndex(this.selectionModel.selected[0])!;

        selectedOptionOffset += countGroupLabelsBeforeOption(selectedOptionOffset, this.options, this.optionGroups);

        // We must maintain a scroll buffer so the selected option will be scrolled to the
        // center of the overlay panel rather than the top.
        /* tslint:disable-next-line:no-magic-numbers */
        const scrollBuffer = panelHeight / 2;
        this.scrollTop = this.calculateOverlayScroll(selectedOptionOffset, scrollBuffer, maxScroll);
        this.offsetY = this.calculateOverlayOffsetY();

        this.checkOverlayWithinViewport(maxScroll);
    }
github positive-js / mosaic / src / lib / select / select.component.ts View on Github external
private scrollActiveOptionIntoView(): void {
        const activeOptionIndex = this.keyManager.activeItemIndex || 0;
        const labelCount = countGroupLabelsBeforeOption(activeOptionIndex, this.options, this.optionGroups);

        this.panel.nativeElement.scrollTop = getOptionScrollPosition(
            activeOptionIndex + labelCount,
            this.getItemHeight(),
            this.panel.nativeElement.scrollTop,
            SELECT_PANEL_MAX_HEIGHT
        );
    }
github positive-js / mosaic / packages / mosaic / autocomplete / autocomplete-trigger.directive.ts View on Github external
private scrollToOption(): void {
        const index = this.autocomplete.keyManager.activeItemIndex || 0;
        const labelCount = countGroupLabelsBeforeOption(index,
            this.autocomplete.options, this.autocomplete.optionGroups);

        const newScrollPosition = getOptionScrollPosition(
            index + labelCount,
            AUTOCOMPLETE_OPTION_HEIGHT,
            this.autocomplete.getScrollTop(),
            AUTOCOMPLETE_PANEL_HEIGHT
        );

        this.autocomplete.setScrollTop(newScrollPosition);
    }
github positive-js / mosaic / packages / mosaic / select / select.component.ts View on Github external
private scrollActiveOptionIntoView(): void {
        const activeOptionIndex = this.keyManager.activeItemIndex || 0;
        const labelCount = countGroupLabelsBeforeOption(activeOptionIndex, this.options, this.optionGroups);

        this.optionsContainer.nativeElement.scrollTop = getOptionScrollPosition(
            activeOptionIndex + labelCount,
            this.getItemHeight(),
            this.optionsContainer.nativeElement.scrollTop,
            SELECT_PANEL_MAX_HEIGHT
        );
    }