Skip to content

Cropper in modal broken after Chrome update to 61.0.3163.100 #32

@rcortino

Description

@rcortino

Discovered that when the cropper is implemented in a modal, that the coordinates retrieved from event.getRelativeX(this._container.getElement()), event.getRelativeY(this._container.getElement()) are not valid. The coordinates appear to retrieve the coordinate of the mouse within the window.

I was able to resolve this by changing the coordinates used to event.getClientX() and event.getClientY(), then adjusting the coordinates to be relative to _container.getAbsoluteTop(), and _container.getAbsoluteLeft();

While I know this is a working fix for my situation, I have not verified that this change would adversely affect other implementations.

public void onMouseMove(MouseMoveEvent event) {

    if (this.isDown) {     
    	int cX = event.getClientX();     
    	int cY = event.getClientY();    	       	
    	int cT = this._container.getAbsoluteTop();
    	int cL = this._container.getAbsoluteLeft();        	
    	int x = cX - cL;
    	int y = cY - cT;
            this.provideDragging(x,y); 
            this.updatePreviewWidget();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions