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

how to turn lock aspect ratio on/off programmatically

Open raykudo opened this issue 4 years ago β€’ 2 comments

codesandbox

As you can see in the sandbox, lock-aspect-ratio property works as expected. However, I'd like to change width/height programmatically with a different aspect ratio from the original one and then make lock-aspect-ratio active again. Any possible ways to do this? I wanna stick with the same lock-aspect-ratio when it comes to resizing.

setSize: function () {
  # something like this.$refs.vueDraggableResizeable.lockAspectRatio = false
  this.w = 300;
  this.h = 100;
  # something like this.$refs.vueDraggableResizeable.lockAspectRatio = true 
}

raykudo avatar May 20 '21 09:05 raykudo

<vue-draggable-resizable
    :w="w"
    :h="h"
    :x="x"
    :y="y"
    @dragging="onDrag"
    @resizestop="onResizeStop"
    :parent="true"
    :lock-aspect-ratio="lock"
  >

data: function () {
    return {
      lock: true,
      w: 200,
      h: 200,
      x: 0,
      y: 0,
    };
  },

setSize: function () {
  this.lock = false;
  this.w = 300;
  this.h = 100;
  this.lock = true;
}

thought this works, but doesn't. if I set this.lock = true again, it constraints the aspect with initial one.

raykudo avatar May 20 '21 09:05 raykudo

setSize: function () {
  # something like this.$refs.vueDraggableResizeable.lockAspectRatio = false
  this.w = 300;
  this.h = 100;
  this.$nextTick(function () {
      # something like this.$refs.vueDraggableResizeable.lockAspectRatio = true 
  });
}

it`s worksπŸ˜„πŸ˜„πŸ˜„πŸ˜„

iCloudys avatar Aug 06 '21 11:08 iCloudys