Fix for #1197. Setting dx to 'null' when declared, as initial check fails (dx === undefined at the start)