Molecular motion under stochastic gating