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

I have text in a canvas and want to re-position inside a canvas, co-ordinates x & y is working but right and bottom is not working #991

Open
atifqadeer opened this issue Dec 10, 2022 · 0 comments

Comments

@atifqadeer
Copy link

interact("div.mockup").draggable({
inertia: false,
autoScroll: true,
onmove: dragMoveListener,
modifiers: [
interact.modifiers.restrictRect({
restriction: document.querySelector('#sence'),
endOnly: true,
})
]
})
interact(mockup1).draggable({
inertia: false,
autoScroll: true,
onmove: dragMoveListener,
modifiers: [
interact.modifiers.restrictRect({
restriction: document.querySelector('#sence'),
endOnly: true,
})
]
})

 function dragMoveListener (event) {
  var target = event.target,
      x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
      y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;

  // translate the element
  target.style.webkitTransform =
  target.style.transform =
    'translate(' + x + 'px, ' + y + 'px)';

  // update the posiion attributes
  target.setAttribute('data-x', x);
  target.setAttribute('data-y', y);
}
@atifqadeer atifqadeer changed the title I have text in a canvas and want to re-position inside a canvas but co-ordinates x & y is working but right and bottom is not working I have text in a canvas and want to re-position inside a canvas, co-ordinates x & y is working but right and bottom is not working Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant