matiasgali / guillotine

jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate.
http://guillotine.js.org
326 stars 100 forks source link

Drag not working in IE10 #12

Closed CristinaNicolae closed 9 years ago

CristinaNicolae commented 9 years ago

On Internet Explorer, the drag option is not working. I am trying to move it to reposition it and it doesn't work. The zoom in and out works.

This is how I use it:

                   var picture = $('#orig_image');
                  picture.on('load', function() {
                                             // Initialize plugin (with custom event)
                                            //  picture.guillotine({eventOnChange: 'guillotinechange'});
                                           //picture.guillotine({width: 200, height: 200});
                    picture.guillotine({
                        eventOnChange : 'guillotinechange',
                        width : ok_width,
                        height : ok_height,
                        zoomStep: 0.1
                    });
                    picture.guillotine('fit');

                    // Display inital data
                    var data = picture.guillotine('getData');
                    for ( var key in data) {
                        $('#' + key).html(data[key]);
                    }

                    // Bind button actions
                    $('#fit').click(function() {
                        picture.guillotine('fit');
                    });
                    $('#zoom_in').click(function() {
                        picture.guillotine('zoomIn');
                    });
                    $('#zoom_out').click(function() {
                        picture.guillotine('zoomOut');
                    });

                    // Update data on change
                    picture.on('guillotinechange', function(ev, data, action) {
                        data.scale = parseFloat(data.scale.toFixed(4));

                        //if scale is bigger than 0.9 disable zoom in button
                        if (data.scale > 0.9) {
                            $('#zoom_in').addClass('disabled');
                        } else {
                            $('#zoom_in').removeClass('disabled');
                        }
                        for ( var k in data) {
                            $('#' + k).html(data[k]);
                        }

                    });
                });

            } else {
                $("#errorMessage").text(json.file);
                $("#errorMessage").removeClass("hidden");
            }
        }
    });

    $('.cropbuttonscontainer').css({
        width : $('#max_w').val()
    });

});

I tried the demo also, and dragging is not working on that too. I have Windows 8 Enterprise with IE 10.0.9200

matiasgali commented 9 years ago

This is certainly an issue, IE10 isn't working with the MSPointer events. There are some pending improvements but I'll have this fixed by the next release.

Thanks for reporting it.

rijint commented 9 years ago

Hi, CristinaNicolae

I had the same problem in IE 10. But i solved it by updating the code with the following.

var ua = window.navigator.userAgent; var msie = ua.indexOf ( "MSIE " ); var version = ( msie > 0 ) ? parseInt (ua.substring (msie+5, ua.indexOf (".", msie ))) : 0;

var pointer = (version == 10) ? {down : " mousedown.", move : " mousemove.", up : " mouseup." } : {down : " MSPointerDown.", move : " MSPointerMove.", up : " MSPointerUp." } ;// MSPointer will not support in ie10.

events = { start: "touchstart." + scope + " mousedown." + scope + pointer.down + scope, move: "touchmove." + scope + " mousemove." + scope + pointer.move + scope, stop: "touchend." + scope + " mouseup." + scope + pointer.up + scope };

here i checked the browser. If the browser is ie10 instead of 'MSPointerDown' i used 'mousedown' and the others too. May be this can help you.

CristinaNicolae commented 9 years ago

Hi @rijint ,

Thank you. That works like a charm.