Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to set position programmatically #21

Open
euskalhenriko opened this issue Sep 13, 2018 · 5 comments
Open

Possibility to set position programmatically #21

euskalhenriko opened this issue Sep 13, 2018 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@euskalhenriko
Copy link

Hi!

sometimes I need to set the position programmatically, for example if the window is resized and the draggable element is left out of it.
I do it modifying the position of element manually and accessing the draggable-state via getAttribute to change the startDragPosition and currentDragPosition, but it's tricky

Now is possible? If not, is a possible future feature?

Thank!

@IsraelZablianov IsraelZablianov added the enhancement New feature or request label Sep 13, 2018
@IsraelZablianov IsraelZablianov self-assigned this Sep 13, 2018
@IsraelZablianov
Copy link
Owner

Will be added hopefully in the next version

@mcvova
Copy link

mcvova commented Apr 15, 2019

I do it modifying the position of element manually and accessing the draggable-state via getAttribute to change the startDragPosition and currentDragPosition, but it's tricky

Hi! How did you set the position programmatically? Can you give an example? I tried this code:

let  block = document.querySelector("#block");

let  data = JSON.parse(block .getAttribute('draggable-state'));

 _.merge(data, {
       currentDragPosition: {
              left: 150,
              top: 150
            }            
});

_.merge(data, {
        initialPosition: {
              left: 150,
              top: 150
            }            
 });

_.merge(data, {
       startDragPosition: {
              left: 150,
              top: 150
            }            
});

block.setAttribute('draggable-state', JSON.stringify(data));

@IsraelZablianov
Copy link
Owner

The feature is still not implemented, but what that you wrote should work as a work around

@fabiofdsantos
Copy link

fabiofdsantos commented Apr 23, 2019

@mcvova,

Thanks for sharing! I've introduced code to change css style of the draggable container.

function updateTagPosition(left, top) {
  let block = document.querySelector(".draggable-container");

  let data = JSON.parse(block.getAttribute("draggable-state"));

  _.merge(data, {
    currentDragPosition: {
      left: left,
      top: top
    }
  });

  _.merge(data, {
    initialPosition: {
      left: left,
      top: top
    }
  });

  _.merge(data, {
    startDragPosition: {
      left: left,
      top: top
    }
  });

  block.setAttribute("draggable-state", JSON.stringify(data));

  block.style.position = "fixed";
  block.style.left = left + "px";
  block.style.top = top + "px";
}

@phtwo
Copy link

phtwo commented Jun 3, 2019

this.draggableValue.initialPosition.left= left
this.draggableValue.initialPosition.top = top
this.draggableValue.resetInitialPos = true
this.$nextTick(() => (this.draggableValue.resetInitialPos = false))

I use initialPosition and resetInitialPos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants