How to use the nav-frontend-js-utils.getViewportDimensions function in nav-frontend-js-utils

To help you get started, we’ve selected a few nav-frontend-js-utils 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 navikt / nav-frontend-moduler / packages / node_modules / nav-frontend-popover / src / popover.tsx View on Github external
break;
            case PopoverOrientering.UnderVenstre:
                left = ankerOffset.left;
                top = ankerOffset.top + ankerOffset.height + avstandTilAnker;
                break;
            case PopoverOrientering.Under:
                left = ankerOffset.left + (ankerOffset.width / 2) - (popoverOffset.width / 2);
                top = ankerOffset.top + ankerOffset.height + avstandTilAnker;
                break;
            default: // PopoverOrientering.Over
                left = ankerOffset.left + (ankerOffset.width / 2) - (popoverOffset.width / 2);
                top = ankerOffset.top - avstandTilAnker - popoverOffset.height;
                break;
        }

        const viewPortDimensions = getViewportDimensions();

        left = Math.max(0, left);
        left = Math.min(Math.abs(left), Math.abs(viewPortDimensions.w - popoverOffset.width));

        const pilLeft = ankerOffset.left + (ankerOffset.width / 2) - left - 1;

        return { left, top, pilLeft };
    }