woutervh-/react-pan-and-zoom-hoc

Bug: normalizeTouchPosition null pointer

blaues0cke opened this issue · 3 comments

For some reasons, on touch devices sometimes normalizeTouchPosition gets called while event.targetTouches contains zero items. This will make this code to fail since the first item (targetTouches[0]) does not exist:

const position = {
    clientX: ('targetTouches' in event) ? event.targetTouches[0].pageX : event.clientX,
    clientY: ('targetTouches' in event) ? event.targetTouches[0].pageY : event.clientY
};

The error then is

undefined is not an object (evaluating 'event.targetTouches[0].pageX')

Hi @blaues0cke

Very strange indeed, since under normal circumstances the normalizeTouchPosition should not be called when there are no pointers in the event. I will investigate this and put in extra safety measures to prevent the error from happening.

Thanks!

Fixed in version 2.1.5

Thank you very much (appeared on an iPad pro running iOS 12). :-)