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

Add framer api option to get cursor coordinates inside the root canvas #110

Open
andirsun opened this issue Nov 13, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@andirsun
Copy link

Describe your use case
I am trying to build a plugin that supports drag and drop to add svg images.

The architecture of my plugin is that is running inside an iframe environment to render a responsive webpage that contains the svgs I want to drag and drop. As inside the iframe I dont have the Draggable component available or framer api available I had to implement a workaround to make drag and drop work.

Currently drag and drop is working inside the iframe but the drop position is not accurate. This is what I am doing.

  1. I send a message to the parent window using this code
parent.postMessage(
        {
          svg,
          name: icon.name,
        },
        '*'
      )
  1. Parent (Framer Plugin) receives the message with the svg and insert it using framer.addSvg function
await framer.addSVG({
      svg,
      name,
    })
  1. The SVG is added but in a random position defined by Framer. In this case I know I can get the SVG node inserted and use setAttributes() to override node attributes, inside those attributes there are options like bottom, top .... but I dont know what are the exact coordinates where the icon was dropped (cursor position).

Describe the solution you'd like

  • You can add an option to get exact coordinates when the cursor is when the svg was dropped so I can use those coordinates to move the inserted icon to that position.

  • Another option is to make framer automatically detect mouse position and add svg using framer.addSVG in that position.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

@andirsun andirsun added the enhancement New feature or request label Nov 13, 2024
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

1 participant