We used to pray while animals passed in front of us. This was mentioned to the Messenger of Allah ﷺ, and he said, "If something like the back of a saddle is placed in front of one of you, then whoever passes beyond it will not harm his prayer."
حدثنا محمد بن عبد الله بن نمير حدثنا عمر بن عبيد عن سماك بن حرب
كنا نصلي والدواب تمر بين أيدينا فذكر ذلك لرسول الله ﷺ فقال مثل مؤخرة الرحل تكون بين يدي أحدكم فلا يضره من مر بين يديه