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

Html rerendering on drag #654

Open
ayberkdikcinar opened this issue Nov 15, 2023 · 0 comments
Open

Html rerendering on drag #654

ayberkdikcinar opened this issue Nov 15, 2023 · 0 comments

Comments

@ayberkdikcinar
Copy link

ayberkdikcinar commented Nov 15, 2023

Hi,

I have a problem that is about rendering some html for the nodes. In my html, the nodes actually consist of an image, text and some specified colors. And the images are taken from the internet via .src

Here is the code that I mentioned above;

nodeThreeObject={(node) => {
       const nodeContainer = document.createElement("div");
       nodeContainer.className = "node-container";

       const nodeEl = document.createElement("div");
       nodeEl.className = "node-label";
       nodeEl.textContent = node.name;
       if (node.nodeType === "lifecycle" && node.deletedAt) {
         nodeEl.style.color = NodeStyling[node.nodeType].deletedColor;
       } else {
         nodeEl.style.color = NodeStyling[node.nodeType].color;
       }

       nodeEl.style.fontSize = NodeStyling[node.nodeType]?.fontSize;
       const imgElement = document.createElement("img");
       imgElement.className = "node-image";
       imgElement.textContent = node.name;
       imgElement.src = node.imageUrl || ""; //TODO: extra refetches happening on the graph when I change locations of the nodes (dragging).

       nodeContainer.appendChild(imgElement);
       nodeContainer.appendChild(nodeEl);

       return new CSS2DObject(nodeContainer);
     }}
     

It refetches the images on dragging. I want to fetch images only 1 time (when initial render happens ) and use them until I change them manually.

Is there any solution for that? Im also not sure the problem is about 3d-force-graph. However, I need some answers for this.

I will be apporociate for your helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant