Code Monkey home page Code Monkey logo

Comments (4)

valgeirb avatar valgeirb commented on May 10, 2024

Is there an easy solution to make vue3-popper work with SVG ?

Unfortunately for your case, I don't think so since Popper is currently unable to be "renderless" as in not rendering any element except the one that it wraps. I don't know if that's even possible.

SVGs can have HTML in them using <foreignObject/> according to Google 😄 but I don't know anything more about that.

Thanks for the reproduction, I cloned your repo and it's an interesting problem, I just don't see the solution at the moment.

from vue3-popper.

simevo avatar simevo commented on May 10, 2024

@valgeirb thanks for the quick reply!

We have used foreignObject but as far as I can tell it requires to fix position and size, which is complicated here. The best would be to place the additional HTML elements outside the SVG.

Do you think it would be feasible to create a <PopperDetached> component to be used like this:

<template>
  <PopperDetached
    v-for="(d, name) in districts"
    :key="name"
    :hover="true"
    :trigger="name">
    <template #content>
      ...
    </template>
  </PopperDetached>
  <svg
    ...
  >
    <g>
      <path
        v-for="(d, name) in districts"
        :key="name"
        :id="name"
        ...
      />
    </g>
  </svg>
</template>

(based on the non-working code here: https://gitlab.com/simevo/vue3-svg-map/-/blob/vue3-popper/src/components/MapMaharashtra.vue)

Notice the trigger prop which is used to pass the id of the SVG element that actually triggers the popper.

from vue3-popper.

dgedwards13 avatar dgedwards13 commented on May 10, 2024

I have a similar use case that I'd love an implementation for. Any update here? The PopperDetached option @simevo mentions would work fine for us too.

from vue3-popper.

bertBruynooghe avatar bertBruynooghe commented on May 10, 2024

Had a similar issue, and solved it using foreignObject (to allow nested HTML in the svg) and Teleport (to move the tooltip to a place in the DOM outside the svg.

from vue3-popper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.