private void continueDragging(final MouseMoveEvent event) {
        if (dragging) {
            final int x = event.getClientX();
            final int y = event.getClientY();
            double dx = x - dragStartX;
            double dy = y - dragStartY;

            if (resizeWidth || resizeHeight) {
                final Widget widget = getWidget();
                final Element elem = widget.getElement();
                final Size widthSize = popupSize.getWidth();
                final Size heightSize = popupSize.getHeight();

                if (resizeWidth && widthSize != null && widthSize.isResizable()) {
                    double newWidth = moveX
                            ? dragStartWindow.getWidth() - dx
                            : dragStartWindow.getWidth() + dx;
                    double constrainedWidth = newWidth;

                    // Constrain width.
                    if (widthSize.getMin() != null) {
                        constrainedWidth = Math.max(constrainedWidth, widthSize.getMin());
                    }
                    if (widthSize.getMax() != null) {
                        constrainedWidth = Math.min(constrainedWidth, widthSize.getMax());
                    }
                    // Add window based size constraint.
                    constrainedWidth = Math.min(initialWindowWidth, constrainedWidth);

                    // If we were constrained then reduce the move distance.
                    double constraintDiff = newWidth - constrainedWidth;
                    dx = dx + constraintDiff;

                    elem.getStyle().setPropertyPx("width", (int) constrainedWidth);
                }
                if (resizeHeight && heightSize != null && heightSize.isResizable()) {
                    double newHeight = moveY
                            ? dragStartWindow.getHeight() - dy
                            : dragStartWindow.getHeight() + dy;
                    double constrainedHeight = newHeight;

                    // Constrain height.
                    if (heightSize.getMin() != null) {
                        constrainedHeight = Math.max(constrainedHeight, heightSize.getMin());
                    }
                    if (heightSize.getMax() != null) {
                        constrainedHeight = Math.min(constrainedHeight, heightSize.getMax());
                    }
                    // Add window based size constraint.
                    constrainedHeight = Math.min(initialWindowHeight, constrainedHeight);

                    // If we were constrained then reduce the move distance.
                    double constraintDiff = newHeight - constrainedHeight;
                    dy = dy + constraintDiff;

                    elem.getStyle().setPropertyPx("height", (int) constrainedHeight);
                }

                // Resize popup contents.
                if (widget instanceof RequiresResize) {
                    final RequiresResize requiresResize = (RequiresResize) widget;
                    requiresResize.onResize();
                }
            }

            if (moveX || moveY) {
                double left = dragStartWindow.getLeft();
                double top = dragStartWindow.getTop();
                if (moveX) {
                    left = left + dx;
                }
                if (moveY) {
                    top = top + dy;
                }

                // Don't constrain if we are resizing.
                if (!resizeWidth && !resizeHeight) {
                    // Add some constraints to stop the dialog being moved off screen.
                    //            left = Math.max(0, Math.min(Window.getClientWidth() - getOffsetWidth(), left));
                    //            top = Math.max(0, Math.min(Window.getClientHeight() - getOffsetHeight(), top));
                    left = Math.max(0, Math.min(Window.getClientWidth() - 22, left));
                    top = Math.max(0, Math.min(Window.getClientHeight() - 22, top));
                }

                setPopupPosition((int) left, (int) top);
            }
        }
    }
Called on mouse move in the caption area, continues dragging if it was
started by {@link #beginDragging}.

@param event the mouse move event that continues dragging
@see #beginDragging
@see #endDragging
stroom-core-client-widget/src/main/java/stroom/widget/popup/client/view/ResizableDialog.java