0

I am trying to restrict movement within an element using https://material.angular.io/cdk/drag-drop/overview . The example unfortunately does not work for my project and I can move the example out of the borders.

<div class="example-boundary">
        <div class="example-box" cdkDragBoundary=".example-boundary" cdkDrag>
                I can only be dragged within the dotted container
        </div>
</div>

Any alternative solutions? Does anyone know who I can fix it?

  • According to the documentation, you are doing it correctly, and the demo of that feature on the page that you reference works as expected. So it seems that your problem may be with code that you haven't shown us. Like, perhaps the boundaries of the outer div aren't what you think they are? A simple working example would help folks try to figure it out. Also, see https://stackoverflow.com/questions/55098093/angular-cdk-drag-and-drop-boundary as it looks like you could experience this problem if the size of the outer div changes. – GreyBeardedGeek Aug 05 '23 at 12:27

0 Answers0