Angular Drag drop - not dragging in the right direction when element is rotated
When the element is rotated using transform:rotate(90deg)
and when I am dragging the element it's not dragging in the right direction.
I am using angular material drag and drop cdk.
Here is the
Reproduction Link
angular drag-and-drop angular-material2
add a comment |
When the element is rotated using transform:rotate(90deg)
and when I am dragging the element it's not dragging in the right direction.
I am using angular material drag and drop cdk.
Here is the
Reproduction Link
angular drag-and-drop angular-material2
add a comment |
When the element is rotated using transform:rotate(90deg)
and when I am dragging the element it's not dragging in the right direction.
I am using angular material drag and drop cdk.
Here is the
Reproduction Link
angular drag-and-drop angular-material2
When the element is rotated using transform:rotate(90deg)
and when I am dragging the element it's not dragging in the right direction.
I am using angular material drag and drop cdk.
Here is the
Reproduction Link
angular drag-and-drop angular-material2
angular drag-and-drop angular-material2
edited Jan 2 at 13:52
Borad Akash
asked Jan 2 at 12:25
Borad AkashBorad Akash
332214
332214
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Use cdkDrag
and transformation
at different level. Try this
<div class="example-box" cdkDrag>
<div style="transform:rotate(90deg)">
Drag me around
</div>
</div>
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
add a comment |
.directive('dragg', function($document) {
return function($scope, $element, $attr) {
var startX = 0,
startY = 0;
var newElement = angular.element('<div class="dragdrop"></div>');
$element.append(newElement);
newElement.on('mousedown', function($event) {
event.preventDefault();
// To keep the last selected box in front
angular.element(document.querySelectorAll('.contentBox')).css('z-index', '1');
$element.css('z-index', '2');
startX = $event.pageX - $element[0].offsetLeft;
startY = $event.pageY - $element[0].offsetTop;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
function mousemove($event) {
placeNode( $element , $event.pageY - startY , $event.pageX - startX, $element);
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
});
Plunker
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006360%2fangular-drag-drop-not-dragging-in-the-right-direction-when-element-is-rotated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use cdkDrag
and transformation
at different level. Try this
<div class="example-box" cdkDrag>
<div style="transform:rotate(90deg)">
Drag me around
</div>
</div>
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
add a comment |
Use cdkDrag
and transformation
at different level. Try this
<div class="example-box" cdkDrag>
<div style="transform:rotate(90deg)">
Drag me around
</div>
</div>
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
add a comment |
Use cdkDrag
and transformation
at different level. Try this
<div class="example-box" cdkDrag>
<div style="transform:rotate(90deg)">
Drag me around
</div>
</div>
Use cdkDrag
and transformation
at different level. Try this
<div class="example-box" cdkDrag>
<div style="transform:rotate(90deg)">
Drag me around
</div>
</div>
answered Jan 2 at 12:43
Parshwa ShahParshwa Shah
518314
518314
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
add a comment |
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
Thanks but it won't rotate the element if element is rectangle
– Borad Akash
Jan 2 at 12:53
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
That is another requirement. Mention all requirement and alternate flows in post
– Parshwa Shah
Jan 2 at 12:56
add a comment |
.directive('dragg', function($document) {
return function($scope, $element, $attr) {
var startX = 0,
startY = 0;
var newElement = angular.element('<div class="dragdrop"></div>');
$element.append(newElement);
newElement.on('mousedown', function($event) {
event.preventDefault();
// To keep the last selected box in front
angular.element(document.querySelectorAll('.contentBox')).css('z-index', '1');
$element.css('z-index', '2');
startX = $event.pageX - $element[0].offsetLeft;
startY = $event.pageY - $element[0].offsetTop;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
function mousemove($event) {
placeNode( $element , $event.pageY - startY , $event.pageX - startX, $element);
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
});
Plunker
add a comment |
.directive('dragg', function($document) {
return function($scope, $element, $attr) {
var startX = 0,
startY = 0;
var newElement = angular.element('<div class="dragdrop"></div>');
$element.append(newElement);
newElement.on('mousedown', function($event) {
event.preventDefault();
// To keep the last selected box in front
angular.element(document.querySelectorAll('.contentBox')).css('z-index', '1');
$element.css('z-index', '2');
startX = $event.pageX - $element[0].offsetLeft;
startY = $event.pageY - $element[0].offsetTop;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
function mousemove($event) {
placeNode( $element , $event.pageY - startY , $event.pageX - startX, $element);
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
});
Plunker
add a comment |
.directive('dragg', function($document) {
return function($scope, $element, $attr) {
var startX = 0,
startY = 0;
var newElement = angular.element('<div class="dragdrop"></div>');
$element.append(newElement);
newElement.on('mousedown', function($event) {
event.preventDefault();
// To keep the last selected box in front
angular.element(document.querySelectorAll('.contentBox')).css('z-index', '1');
$element.css('z-index', '2');
startX = $event.pageX - $element[0].offsetLeft;
startY = $event.pageY - $element[0].offsetTop;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
function mousemove($event) {
placeNode( $element , $event.pageY - startY , $event.pageX - startX, $element);
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
});
Plunker
.directive('dragg', function($document) {
return function($scope, $element, $attr) {
var startX = 0,
startY = 0;
var newElement = angular.element('<div class="dragdrop"></div>');
$element.append(newElement);
newElement.on('mousedown', function($event) {
event.preventDefault();
// To keep the last selected box in front
angular.element(document.querySelectorAll('.contentBox')).css('z-index', '1');
$element.css('z-index', '2');
startX = $event.pageX - $element[0].offsetLeft;
startY = $event.pageY - $element[0].offsetTop;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});
function mousemove($event) {
placeNode( $element , $event.pageY - startY , $event.pageX - startX, $element);
}
function mouseup() {
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
};
});
Plunker
answered Feb 13 at 16:59
Mikhail MalakhveiMikhail Malakhvei
495
495
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006360%2fangular-drag-drop-not-dragging-in-the-right-direction-when-element-is-rotated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown