moveable icon indicating copy to clipboard operation
moveable copied to clipboard

How to limit the drag range using react-moveable

Open Bain-liu opened this issue 6 years ago • 9 comments

Environments

  • Framework name:
  • Framework version:
  • Moveable Component version:
  • Testable Address(optional):

Description

Bain-liu avatar Mar 10 '20 08:03 Bain-liu

container:Invalid attribute

Bain-liu avatar Mar 10 '20 08:03 Bain-liu

image

Bain-liu avatar Mar 11 '20 01:03 Bain-liu

@liuxuehuax

Use bounds props.

{ left : 0, right: width, top: 0, bottom: height }

daybrush avatar Mar 14 '20 06:03 daybrush

@daybrush Doesn't seem to be of much use Would you like to try it? https://codesandbox.io/s/fervent-microservice-vj86d

Bain-liu avatar Mar 14 '20 08:03 Bain-liu

image

Bain-liu avatar Mar 14 '20 08:03 Bain-liu

@daybrush sorry,my question! Thank you~

Bain-liu avatar Mar 14 '20 08:03 Bain-liu

this.moveable.bounds = { left: offset.left, right: offset.left + (bg.width() || 0), top: offset.top, bottom: offset.top + (bg.height() || 0) } it not work

new Moveable(this.$refs.workspace, {bounds:{ left: offset.left, right: offset.left + (bg.width() || 0), top: offset.top, bottom: offset.top + (bg.height() || 0) }}) it works

how to reset the bounds?

leeboo avatar Mar 20 '20 02:03 leeboo

@leeboo

use bounds with snappable.

new Moveable(..., {
    snappable: true,
    bounds: { .... },
});

daybrush avatar Mar 29 '20 14:03 daybrush

@daybrush sorry,my question! Thank you~

怎么解决的?

o0Chivas0o avatar Mar 18 '21 04:03 o0Chivas0o