3

I use a open source project that is no longer maintained: https://github.com/timmywil/jquery.panzoom

I has worked well with the jquery 3 beta, but is broken since the official release.

The problem seems to be $.event.mouseHooks, it has been deprecated by jQuery. Is there any workaround for this or do I have to look for another panzoom functionality?

(also, if you have a suggestion for a replacement feel free to share)

Krillko
  • 626
  • 1
  • 8
  • 19

2 Answers2

0

I ran into the same issue and couldn't fix it.

I had to roll JQuery back to alpha to fix this.
http://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js

jrenouard
  • 407
  • 6
  • 8
0

I had the same problem and solved it by using jquery-migrate and copying the mouseHooks code from version 1.12.4:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.0.1.js"></script>

<script type="text/javascript">
    jQuery.event.mouseHooks = {
        props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
            "pageX pageY screenX screenY toElement" ).split( " " ),
        filter: function( event, original ) {
            var body, eventDoc, doc,
                button = original.button,
                fromElement = original.fromElement;

            // Calculate pageX/Y if missing and clientX/Y available
            if ( event.pageX == null && original.clientX != null ) {
                eventDoc = event.target.ownerDocument || document;
                doc = eventDoc.documentElement;
                body = eventDoc.body;

                event.pageX = original.clientX +
                    ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
                    ( doc && doc.clientLeft || body && body.clientLeft || 0 );
                event.pageY = original.clientY +
                    ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) -
                    ( doc && doc.clientTop  || body && body.clientTop  || 0 );
            }

            // Add relatedTarget, if necessary
            if ( !event.relatedTarget && fromElement ) {
                event.relatedTarget = fromElement === event.target ?
                    original.toElement :
                    fromElement;
            }

            // Add which for click: 1 === left; 2 === middle; 3 === right
            // Note: button is not normalized, so don't use it
            if ( !event.which && button !== undefined ) {
                event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
            }

            return event;
        }
    };
</script>
bjornoss
  • 26
  • 2