vue-draggable-resizable icon indicating copy to clipboard operation
vue-draggable-resizable copied to clipboard

Programmatically set size does not work correctly

Open RLatypov opened this issue 5 years ago • 9 comments

When you set the size programmatically with the option :lock-aspect-ratio="true", this does not work correctly. Please see an example https://codepen.io/ruslan-latypov/pen/GRJNOmr

case

How can this be fixed?

RLatypov avatar Feb 23 '20 18:02 RLatypov

Looks like a bug. @mauricius should look at this issue.

TitanFighter avatar Feb 23 '20 19:02 TitanFighter

@TitanFighter @mauricius any updates?

RLatypov avatar Feb 26 '20 14:02 RLatypov

I'm not really sure what the issue is here. It looks like that it is something related to the Vuejs reactivity mechanism because I'm not always able to replicate it. However I can tell you that you can remove the onResize handler from your code, because there's no need to set back the values for x, y, w and h. First of all they are already coming from the component, but also they are ignored during dragging and resizing. You can use the resizestop event if you want to keep them in sync. Alternatively you can use the key prop to force the component to the initial state, since the values in your parent component did not change.

mauricius avatar Mar 01 '20 11:03 mauricius

@mauricius I replaced the method onResize toresizestop, thanks for the hint. I see the size is not set, because the condition is false: https://github.com/mauricius/vue-draggable-resizable/blob/56cef60abb34eeac95c2c19e9c88c6bea6d197f9/src/components/vue-draggable-resizable.vue#L811 I can do this.$children[0].rawBottom = this.h but this is not the right way.

RLatypov avatar Mar 02 '20 10:03 RLatypov

same here, actually, we want to some api to set values for x, y, w dynamicly and h to handle the boundary issues or something else. waiting for your feedback, tks. example as below:

private onDrag(left: number, top: number) {
    if (top < 0) {
      this.dragPic.y = 0
     ......
    }
    if (left < 0) {
      this.dragPic.x = 0
      ....
    }
  }

skylingfly avatar Jul 15 '20 11:07 skylingfly

same here, actually, we want to some api to set values for x, y, w dynamicly and h to handle the boundary issues or something else. waiting for your feedback, tks. example as below:

private onDrag(left: number, top: number) {
    if (top < 0) {
      this.dragPic.y = 0
     ......
    }
    if (left < 0) {
      this.dragPic.x = 0
      ....
    }
  }

we want to some api to set values for x, y, w dynamicly and h to handle the boundary i +1

Flourad avatar Dec 23 '20 08:12 Flourad

I'm not really sure what the issue is here. It looks like that it is something related to the Vuejs reactivity mechanism because I'm not always able to replicate it. However I can tell you that you can remove the onResize handler from your code, because there's no need to set back the values for x, y, w and h. First of all they are already coming from the component, but also they are ignored during dragging and resizing. You can use the resizestop event if you want to keep them in sync. Alternatively you can use the key prop to force the component to the initial state, since the values in your parent component did not change.

How to use the resizestop and the ky prop? Could you give a demo?

Flourad avatar Dec 23 '20 09:12 Flourad

resizestop -> https://github.com/mauricius/vue-draggable-resizable#resizestop key is a vue's built-in prop, it is not module specific -> https://vuejs.org/v2/api/#key

TitanFighter avatar Dec 23 '20 22:12 TitanFighter

resizestop -> https://github.com/mauricius/vue-draggable-resizable#resizestop key is a vue's built-in prop, it is not module specific -> https://vuejs.org/v2/api/#key

Thx

Flourad avatar Dec 26 '20 12:12 Flourad