During the double slit experiment the electron passes through both slits, how come the material between the two slits does not collapse the wave function and we get an interference pattern? On the other hand, the photon gun's photons on the other side (the observer person's tool) does collapse it. Does it impart more energy than the material?
I would be careful about saying that "the electron goes through both slits", as that is simply not the right way to think about it. Rather, the photon will be in some superposition eigenstates as it passes through the slits.
Having said that, realize that anything that hits the barrier is going to bounce right off and not make it through. The moment that the photon hits the barrier it is in a position eigenstate. So in that sense, the barrier does collapse the wave function if it hits it. If it doesn't then the photon will remain in a superposition.