probil / vue-moveable

↔️ ↕️ 🔄 Vue.js wrapper for Moveable
https://vue-moveable.netlify.com/
MIT License
966 stars 69 forks source link

setState method not working in 1.8.2 version #138

Open katOstrynska opened 4 years ago

katOstrynska commented 4 years ago

I just updated to 1.8.2 version of this plugin and I cannot set values for my state;

https://github.com/probil/vue-moveable/issues/84#issuecomment-609399892

I removed additional moveable instance from this.$refs.moveable.setState(); but it still do not work.

I have got something like this in mounted function:

this.$refs.moveable.setState(() => {
  this.moveable.scalable = true;
  this.moveable.resizable = false;
  this.moveable.keepRatio = true;
  this.moveable.draggable = true;
  this.moveable.rotatable = true;
 });

And my data:

data() {
    return {
       moveable: {
         draggable: false,
         resizable: false,
         scalable: false,
         rotatable: false,
         keepRatio: true,
         pinchable: true,
         snappable: true,
         verticalGuidelines: [100, 200, 300],
         horizontalGuidelines: [0, 100, 200],
         renderDirections: ["nw", "ne", "sw", "se"],
         container: document.getElementById(`${this.parentId}`),
         className: `moveable-box moveable-${this.el.id}`,
         target: '.target'
      }
   }
}
probil commented 4 years ago

Hi @katOstrynska Are there any errors in the console when you call this.$refs.moveable.setState ? Can you tell me what's the sign that it's not work?


BTW if you use v-bind with moveable you can change moveable configuration in your instance's data directly. Component will sync that change with inner moveable instance automatically