If the element or his parent is in position: fixed, the rotation doesn't work fine when you scroll.
For fix, you have to use clientX and clientY here instead of pageX and pageY:
p.onRotated = function (event) {
if (this.active === true) {
event.stopPropagation();
event.preventDefault();
if (event.touches !== undefined && event.touches[0] !== undefined) {
this.lastMouseEvent = {
pageX: event.touches[0].clientX,
pageY: event.touches[0].clientY
}
} else {
this.lastMouseEvent = {
pageX: event.clientX,
pageY: event.clientY
}
}
}
}