PixelsCommander / Propeller

JavaScript library to rotate elements with mouse or touch gestures. Supports inertia and stepwise rotation. Optimized for better performance.
http://pixelscommander.com/polygon/propeller/
409 stars 58 forks source link

Rotation bug if target element or parent as position:fixed. #10

Open Paupy opened 10 years ago

Paupy commented 10 years ago

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
            }
        }
    }
}
PixelsCommander commented 10 years ago

Hi, sorry for late answer and thanks for the fix proposed, will check and add it asap, you may create a pull request if possible