Comments (8)
Hi @ibadass
I didn't quite get your question but I suppose issue #82 is what you are looking for.
You can access getRect()
this way:
this.$refs.moveable.moveable.getRect();
Here is a demo https://codesandbox.io/s/vue-moveable-demo-udvc8?fontsize=14&hidenavigation=1&theme=dark
from vue-moveable.
Hi @probil,
Thank you for your answer !
I'll try to explain my issue with more details :
On my webpage, I can add a new moveable object in a container, after manupulate it, I can "save" it in a DB. In my DB, I save this infos (from getRect()
) :
{
"label": "XXX",
"width": 191,
"height": 50,
"left":335,
"top":121,
"pos1": {x: 335, y: 121},
"pos2": {x: 535, y: 121},
"pos3": {x: 335, y: 221},
"pos4": {x: 535, y: 221}
}
My goal is : when I land on my page (with the container), is there a possibility to "autocreate" a moveable object with the infos from my DB ?
Thank you.
from vue-moveable.
@ibadass It's possible. You just need to store internal state of moveable positions it in component's data
. For example you can utilize Frame
from scenejs
(which internally used by moveable
):
import { Frame } from 'scenejs';
const frame = new Frame({
width: '300px',
height: '200px',
left: '0px',
top: '0px',
transform: {
rotate: '0deg',
scaleX: 1,
scaleY: 1,
matrix3d: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
},
});
Now you need to convert the resulting CSS and feed to moveable:
target.style.cssText = frame.toCSS();
I've used this approach earlier here :
https://github.com/probil/vue-moveable/blob/1704c3401cefdfd6afc87e1cdc8d48db3f91b85b/src/App.vue
I don't have time right now to show you the exact solution on codesandbox but this information should lead you to the right direction. I hope it will help. Let me know about the outcome
from vue-moveable.
Hi @probil,
Thank you for your answer.
J'ai essayé la méthode, mais je n'arrive pas à résoudre mon problème. Si tu as le temps, je ne dis pas non, pour un peu d'aide...
Thanks in advance.
from vue-moveable.
Hi @probil
I have similar problem with my elements beeing imported from DB. When I want to edit elements from DB, I don't have 'moveable' initialized -> my this.$refs.moveable.moveable is undefined.
How to initialize moveable for elements from DB?
from vue-moveable.
I had some trouble knowing how to feed the moveable new CSS, but the following worked for me.
My ref for the moveable is player1
this.$refs.player1.moveable.target.style.cssText
from vue-moveable.
@jeffreykthomas How did you do exactly? I have a getRect() object in a DB (this.data), which i try to assign to a Moveable ref like this in mounted hook:
this.$refs.parmOne.moveable.target.style.cssText = this.data.toCSS();
My ref is called parmOne and is assigned to the Moveable component.
But nothing gets assigned. cssText is empty when i console.log it.
from vue-moveable.
Not sure if this could be the difference, but you may need to utilize the Frame method from scenejs (installed as a separate package) to use this process
Within my app the full process is:
Within computed:
player1Position(){ let frame = new Frame(this.pawnFrames[0].frame); return frame.toCSS() }
And then in updated hook:
this.$refs.player1.moveable.target.style.cssText = this.player1Position
from vue-moveable.
Related Issues (20)
- [idea] Droppable
- Does anyone know how to create a group?
- Getting selected model Id
- Creating new instance of vue-moveable
- Action Required: Fix Renovate Configuration
- How to initialize the position of the rectangle
- Click event not firing
- Moveable Editable With Buttons HOT 1
- Resizing from lower right corner gets out of sync with pointer position if the pointer moves quickly
- Bounds parameter doesn't work for scaling
- Accessing and changing property of 'moveable-control-box'
- The target attribute is set to an empty array, an error occurs in the console HOT 1
- How to manage the switching of multiple moving objects
- How to set min-width & min-height (without css hacks)
- nuxt typescript HTMLElement is not defined
- 牛逼
- Dependency Dashboard
- Is there a way to snap Resize, Drag, and Rotate to a configurable grid? HOT 1
- How to import vue-moveable using CDN ????
- I customized ables in vue2.0 and never displayed them. I don't know why HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-moveable.