yairEO / fancyInput

Makes typing in input fields fun with CSS3 effects
1.93k stars 283 forks source link

Got rid of offsetLeft error when charsToRemove is zero length and added ... #40

Closed JudeOsborn closed 10 years ago

JudeOsborn commented 10 years ago

...a destroy parameter to clear events.

When hitting backspace on an empty input box I was getting "Uncaught TypeError: Cannot read property 'offsetLeft' of undefined" on line 166. So I'm checking charsToRemove for length now.

I also added a parameter called "dest" and a function called "destroy" that let you remove all events. This was needed for a project where fancyInput had to be initialized and de-initialized regularly. Without this, the key events were duplicating, causing characters to be typed multiple times because the events are assigned to the document. So simply setting a parameter to true clears the events immediately, like this:

$someInput.fancyInput(true);