keep the popup template inside the viewport