All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dominokit.domino.ui.popover.PopupPositionTopDown Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package org.dominokit.domino.ui.popover;

import elemental2.dom.ClientRect;
import elemental2.dom.DomGlobal;
import elemental2.dom.HTMLElement;

/**
 * Use {@link PopupPositionBestFit}
 */
@Deprecated
public class PopupPositionTopDown implements PopupPosition {

    private String positionClass;

    @Override
    public void position(HTMLElement popup, HTMLElement target) {
        ClientRect targetRect = target.getBoundingClientRect();

        double distanceToMiddle = ((targetRect.top) - (targetRect.height / 2));
        double windowMiddle = DomGlobal.window.innerHeight / 2;

        if (distanceToMiddle >= windowMiddle) {
            PopupPosition.TOP.position(popup, target);
            this.positionClass = PopupPosition.TOP.getDirectionClass();
        } else {
            PopupPosition.BOTTOM.position(popup, target);
            this.positionClass = PopupPosition.BOTTOM.getDirectionClass();
        }
    }

    @Override
    public String getDirectionClass() {
        return positionClass;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy