Drop one or more Animated Borders on your clip, set the border size, corner roundness, the color including “edge” color, an optional Drop Shadow. Then choose when the animation starts and stops for in and out (in % of length of clip).
Included is Pan – SC which can exactly match the Border animations to “slide” your subject to a new “fit” inside the border.
Requires FCPX 10.4.10 or higher.