Angular Drag drop - not dragging in the right direction when element is rotated












0















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



enter image description here










share|improve this question





























    0















    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



    enter image description here










    share|improve this question



























      0












      0








      0








      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



      enter image description here










      share|improve this question
















      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



      enter image description here







      angular drag-and-drop angular-material2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 13:52







      Borad Akash

















      asked Jan 2 at 12:25









      Borad AkashBorad Akash

      332214




      332214
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Use cdkDrag and transformation at different level. Try this



          <div class="example-box" cdkDrag>
          <div style="transform:rotate(90deg)">
          Drag me around
          </div>
          </div>





          share|improve this answer
























          • 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



















          0














          .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






          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            Use cdkDrag and transformation at different level. Try this



            <div class="example-box" cdkDrag>
            <div style="transform:rotate(90deg)">
            Drag me around
            </div>
            </div>





            share|improve this answer
























            • 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
















            0














            Use cdkDrag and transformation at different level. Try this



            <div class="example-box" cdkDrag>
            <div style="transform:rotate(90deg)">
            Drag me around
            </div>
            </div>





            share|improve this answer
























            • 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














            0












            0








            0







            Use cdkDrag and transformation at different level. Try this



            <div class="example-box" cdkDrag>
            <div style="transform:rotate(90deg)">
            Drag me around
            </div>
            </div>





            share|improve this answer













            Use cdkDrag and transformation at different level. Try this



            <div class="example-box" cdkDrag>
            <div style="transform:rotate(90deg)">
            Drag me around
            </div>
            </div>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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













            0














            .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






            share|improve this answer




























              0














              .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






              share|improve this answer


























                0












                0








                0







                .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






                share|improve this answer













                .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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 13 at 16:59









                Mikhail MalakhveiMikhail Malakhvei

                495




                495






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas