dist/js/cropjs.js
function () {
            var _this = this;

            window.addEventListener(
                'resize',
                function () {
                    _this.onResize(event);
                },
                false
            );

            this._canvas.addEventListener(
                'dblclick',
                function(event) {
                    return _this.onDoubleClick(event);
                }
            );

            this._canvas.addEventListener(
                'mousedown',
                function (event) {
                    _this.onMouseDown(event);
                }
            );

            this._canvas.addEventListener(
                'mouseup',
                function (event) {
                    _this.onMouseUp(event);
                }
            );

            window.addEventListener(
                'mouseup',
                function (event) {
                    _this.onMouseUp(event);
                }
            );

            this._canvas.addEventListener(
                'mousemove',
                function (event) {
                    _this.onMouseMove(event);
                }
            );

            this._canvas.addEventListener(
                'mousewheel',
                function (event) {
                    event.stopPropagation();
                    event.preventDefault();
                    _this.onMouseWheel(event);
                    return false;
                },
                false
            );

            document.addEventListener(
                'keydown',
                function (e) {
                    var keyCode = e.keyCode || e.which;

                    // Handle escape key
                    if (keyCode === 13) {
                        _this._onSave(
                            _this.getSoftcropData()
                        );
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }

                    if (keyCode === 27) {
                        _this._onCancel();
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }

                    // Handle tab key
                    if (keyCode === 9) {
                        var crops = _this._image.getSoftCrops();
                        var current;
                        for (var n = 0; n < crops.length; n++) {
                            if (_this._crop === crops[n]) {
                                current = n;
                                break;
                            }
                        }

                        if (typeof current != 'undefined') {
                            n += (!e.shiftKey) ? 1 : -1;

                            if (n < 0) {
                                n = crops.length - 1;
                            }
                            else if (n + 1 > crops.length) {
                                n = 0;
                            }
                            _this.setActiveCrop(crops[n]);
                        }

                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }
                },
                false
            );
        }
function () {
            var _this = this;

            window.addEventListener(
                'resize',
                function () {
                    _this.onResize(event);
                },
                false
            );

            this._canvas.addEventListener(
                'dblclick',
                function(event) {
                    return _this.onDoubleClick(event);
                }
            );

            this._canvas.addEventListener(
                'mousedown',
                function (event) {
                    _this.onMouseDown(event);
                }
            );

            this._canvas.addEventListener(
                'mouseup',
                function (event) {
                    _this.onMouseUp(event);
                }
            );

            window.addEventListener(
                'mouseup',
                function (event) {
                    _this.onMouseUp(event);
                }
            );

            this._canvas.addEventListener(
                'mousemove',
                function (event) {
                    _this.onMouseMove(event);
                }
            );

            this._canvas.addEventListener(
                'mousewheel',
                function (event) {
                    event.stopPropagation();
                    event.preventDefault();
                    _this.onMouseWheel(event);
                    return false;
                },
                false
            );

            document.addEventListener(
                'keydown',
                function (e) {
                    var keyCode = e.keyCode || e.which;

                    // Handle escape key
                    if (keyCode === 13) {
                        _this._onSave(
                            _this.getSoftcropData()
                        );
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }

                    if (keyCode === 27) {
                        _this._onCancel();
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }

                    // Handle tab key
                    if (keyCode === 9) {
                        var crops = _this._image.getSoftCrops();
                        var current;
                        for (var n = 0; n < crops.length; n++) {
                            if (_this._crop === crops[n]) {
                                current = n;
                                break;
                            }
                        }

                        if (typeof current != 'undefined') {
                            n += (!e.shiftKey) ? 1 : -1;

                            if (n < 0) {
                                n = crops.length - 1;
                            }
                            else if (n + 1 > crops.length) {
                                n = 0;
                            }
                            _this.setActiveCrop(crops[n]);
                        }

                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }
                },
                false
            );
        }
function ( ) { var _this = this ; window . addEventListener ( 'resize' , function ( ) { _this . onResize ( event ) ; } , false ) ; this . _canvas . addEventListener ( 'dblclick' , function ( event ) { return _this . onDoubleClick ( event ) ; } ) ; this . _canvas . addEventListener ( 'mousedown' , function ( event ) { _this . onMouseDown ( event ) ; } ) ; this . _canvas . addEventListener ( 'mouseup' , function ( event ) { _this . onMouseUp ( event ) ; } ) ; window . addEventListener ( 'mouseup' , function ( event ) { _this . onMouseUp ( event ) ; } ) ; this . _canvas . addEventListener ( 'mousemove' , function ( event ) { _this . onMouseMove ( event ) ; } ) ; this . _canvas . addEventListener ( 'mousewheel' , function ( event ) { event . stopPropagation ( ) ; event . preventDefault ( ) ; _this . onMouseWheel ( event ) ; return false ; } , false ) ; document . addEventListener ( 'keydown' , function ( e ) { var keyCode = e . keyCode || e . which ; // Handle escape key if ( keyCode === 13 ) { _this . _onSave ( _this . getSoftcropData ( ) ) ; e . preventDefault ( ) ; e . stopPropagation ( ) ; return false ; } if ( keyCode === 27 ) { _this . _onCancel ( ) ; e . preventDefault ( ) ; e . stopPropagation ( ) ; return false ; } // Handle tab key if ( keyCode === 9 ) { var crops = _this . _image . getSoftCrops ( ) ; var current ; for ( var n = 0 ; n < crops . length ; n ++ ) { if ( _this . _crop === crops [ n ] ) { current = n ; break ; } } if ( typeof current != 'undefined' ) { n += ( ! e . shiftKey ) ? 1 : - 1 ; if ( n < 0 ) { n = crops . length - 1 ; } else if ( n + 1 > crops . length ) { n = 0 ; } _this . setActiveCrop ( crops [ n ] ) ; } e . preventDefault ( ) ; e . stopPropagation ( ) ; return false ; } } , false ) ; }
Add all event listeners required for drawing and dragging
Add all event listeners required for drawing and dragging