Yes it is needed. If this is taken out, when the user scrolls with the finger, the panel closes, but the entire page also moves along with the direction of scroll. This piece of code prevents the page from moving when the user closes the panel by scrolling.