Loading ...
Sorry, an error occurred while loading the content.

Re: [svg-developers] Re:Pointer event issues with drag and drop (background unresponsive)

Expand Messages
  • Age Bosma
    ... Of course... Many thanks, it works like a charm. I tend to not use things like the root element for things like this for some reason. I see it as something
    Message 1 of 8 , Mar 27, 2009
    • 0 Attachment
      2009/3/26 Frank Bruder <redurbf@...>:
      >
      >> In my case I'm using Batik in a Java application and, like with the
      >> issues with IE, I had to add the mousemove event listener to the
      >> background element.
      >
      > Why not add the mousemove listener to the SVG root element or to the window object? Then the events should bubble up to there, no matter where you move the mouse pointer.
      >

      Of course... Many thanks, it works like a charm. I tend to not use
      things like the root element for things like this for some reason. I
      see it as something special which should not be touched while there's
      not really a reason to do so.

      So what about the normal elements underneath the draggable element?
      I'd like to keep the pointer events on the element to be dragged, but
      this prevents me from determining on which element the draggable
      element is positioned. I.e. mouseup will always give me the dragged
      element as the target instead of the underlying element. How can I
      determine the element underneath?

      Age
    • Robert Longson
      ... use https://developer.mozilla.org/en/DOM/document.elementFromPoint perhaps Best regards Robert
      Message 2 of 8 , Mar 27, 2009
      • 0 Attachment
        --- In svg-developers@yahoogroups.com, Age Bosma <agebosma@...> wrote:

        > So what about the normal elements underneath the draggable element?
        > I'd like to keep the pointer events on the element to be dragged, but
        > this prevents me from determining on which element the draggable
        > element is positioned. I.e. mouseup will always give me the dragged
        > element as the target instead of the underlying element. How can I
        > determine the element underneath?

        use

        https://developer.mozilla.org/en/DOM/document.elementFromPoint

        perhaps

        Best regards

        Robert
      • Age Bosma
        ... I don t see how this would help me. I do know the position of the mouse but this would just give me back the dragged element instead of the element
        Message 3 of 8 , Mar 27, 2009
        • 0 Attachment
          2009/3/27 Robert Longson <longsonr@...>:

          >
          > use
          >
          > https://developer.mozilla.org/en/DOM/document.elementFromPoint
          >
          > perhaps
          >

          I don't see how this would help me. I do know the position of the
          mouse but this would just give me back the dragged element instead of
          the element underneath.

          Age
        • Erik Dahlström
          ... I think in this scenario you really want to make the element you re dragging transparent to mouseevents, by using pointer-events= none on it. You could
          Message 4 of 8 , Mar 27, 2009
          • 0 Attachment
            On Fri, 27 Mar 2009 10:20:41 +0100, Age Bosma <agebosma@...> wrote:

            > 2009/3/26 Frank Bruder <redurbf@...>:
            >>
            >>> In my case I'm using Batik in a Java application and, like with the
            >>> issues with IE, I had to add the mousemove event listener to the
            >>> background element.
            >>
            >> Why not add the mousemove listener to the SVG root element or to the window object? Then the events should bubble up to there, no matter where you move the mouse pointer.
            >>
            >
            > Of course... Many thanks, it works like a charm. I tend to not use
            > things like the root element for things like this for some reason. I
            > see it as something special which should not be touched while there's
            > not really a reason to do so.
            >
            > So what about the normal elements underneath the draggable element?
            > I'd like to keep the pointer events on the element to be dragged, but
            > this prevents me from determining on which element the draggable
            > element is positioned. I.e. mouseup will always give me the dragged
            > element as the target instead of the underlying element. How can I
            > determine the element underneath?

            I think in this scenario you really want to make the element you're dragging "transparent" to mouseevents, by using pointer-events="none" on it. You could store which element you're dragging somewhere, why is it you don't want to do that?

            Cheers
            /Erik

            --
            Erik Dahlstrom, Core Technology Developer, Opera Software
            Co-Chair, W3C SVG Working Group
            Personal blog: http://my.opera.com/macdev_ed
          • Age Bosma
            ... This was my initial plan as well but it s causing other issues. For some reason the draggable element becomes unresponsive when I set the pointer event to
            Message 5 of 8 , Mar 27, 2009
            • 0 Attachment
              2009/3/27 Erik Dahlström <ed@...>:

              >>
              >> So what about the normal elements underneath the draggable element?
              >> I'd like to keep the pointer events on the element to be dragged, but
              >> this prevents me from determining on which element the draggable
              >> element is positioned. I.e. mouseup will always give me the dragged
              >> element as the target instead of the underlying element. How can I
              >> determine the element underneath?
              >
              > I think in this scenario you really want to make the element you're dragging "transparent" to mouseevents, by using pointer-events="none" on it. You could store which element you're dragging somewhere, why is it you don't want to do that?
              >

              This was my initial plan as well but it's causing other issues. For
              some reason the draggable element becomes unresponsive when I set the
              pointer event to 'none' and back again. So if I set the pointer event
              to 'all' after the dragging has been done, I'm not able to drag it
              again for a second time. This is the case until I drag a different
              element. The first one becomes responsive again only after I dragged a
              second one. The seconds one, again, becomes unresponsive after the
              drag until I drag yet another element (the first or a new one).

              What makes it even weirder is adding a path. I create e.g. a circle
              which can be dragged. From this circle I draw I strait line from its
              centre to the middle of the SVG document (first the line, then the
              circle on top of the end of the line, both in a group). The first drag
              goes fine, I can click anywhere on the circle and it moves along with
              the mouse pointer. After the first drag I can not move the circle
              anymore because of the issues mentioned above. This is the case unless
              I move the start of the line along with the circle (item 0 of the
              pathSegList (SVGPathSegMovetoAbs)). When doing this I can drag the
              circle again each time, but only if I position the mouse pointer
              within the bounding box of the line.

              Age
            • Robert Longson
              ... Set the dragged element to display:none while you do it and then set it back. Robert.
              Message 6 of 8 , Mar 27, 2009
              • 0 Attachment
                --- In svg-developers@yahoogroups.com, Age Bosma <agebosma@...> wrote:
                >
                > 2009/3/27 Robert Longson <longsonr@...>:
                >
                > >
                > > use
                > >
                > > https://developer.mozilla.org/en/DOM/document.elementFromPoint
                > >
                > > perhaps
                > >
                >
                > I don't see how this would help me. I do know the position of the
                > mouse but this would just give me back the dragged element instead of
                > the element underneath.

                Set the dragged element to display:none while you do it and then set it back.

                Robert.
              Your message has been successfully submitted and would be delivered to recipients shortly.