Used when someone happens to pass by a place or does something while passing. Often appears in adverbial phrases like 通り掛けに.
I stopped by the bookstore on my way.
A passerby helped me.
Compound of 通り (passing) + 掛け (in the middle of doing), from the verb 通り掛ける.