〜あいだ(に)
Throughout / during a period of timemachine translation
FormationVerb て-form + いる/Noun + の + あいだ(に)
〜あいだ (without に) describes an action that continues THROUGHOUT the whole period: ご飯を食べているあいだ、ずっとテレビを見ていた (the whole time I was eating, I was watching TV nonstop). The second clause usually appears with ずっと and is also a continuing action.
〜あいだに (with に) instead describes something that happens at ONE point within that period: 寝ているあいだに、雨が降った (while I was sleeping, it rained). The second clause is a short, one-time action. This is the key difference between あいだ and あいだに.
What comes before is usually 〜ているあいだ(に) or a noun + の: 夏休みのあいだに (during summer vacation). Unlike 〜ながら (one person doing two things at the same time), 〜あいだに allows the two clauses to have different subjects: 私が寝ているあいだに、母が帰ってきた.
Examples
昼ご飯を食べているあいだ、ずっとテレビを見ていました。
The whole time I was eating lunch, I was watching TV.
私が寝ているあいだに、雨が降ったようです。
It seems it rained while I was sleeping.
夏休みのあいだに、この本を読んでしまいたいです。
I want to finish reading this book during summer vacation.