Prevent undefined behavior on touch events on Android