Add Math.sign for browsers that don't have it like Safari and IE

This fixes speed change when focusing in Safari and IE.