[Tex/LaTex] Beamer slides jump from using `\only`

beamer

I was trying to use \only to dynamically show the some bullets. The problem is that the slides, "First and second" in the following example, will "jump" when I turn to the next page. How can I avoid it? I know if I change \only to \onslide, the slide will not jump. But unlike \only, \onslide has to reserve the space first.

\documentclass{beamer}
\begin{document}
\begin{frame}[plain]
    First and second.\\ % This line will jump while turning page.
    \only<1>{
        \begin{itemize}
            \item 1.a
            \item 1.b
        \end{itemize}
    }
    \only<2>{
        \begin{itemize}
            \item 2.a
            \item 2.b
            \item 2.c
        \end{itemize}
    }

\end{frame}
\end{document}

Best Answer

Use an overlayarea environment, designed specially to prevent those "jumps":

\documentclass{beamer}
\begin{document}
\begin{frame}[plain]

\begin{overlayarea}{\textwidth}{4cm}
    First and second.
    \only<1>{
        \begin{itemize}
            \item 1.a
            \item 1.b
        \end{itemize}
    }
    \only<2>{
        \begin{itemize}
            \item 2.a
            \item 2.b
            \item 2.c
        \end{itemize}
    }
\end{overlayarea}
\end{frame}

\end{document}

The result:

enter image description here