What ingenious methods were used to incorporate SVGs, a static image, hotspots, and JavaScript in this project?

There is a captivating image of a house with SVG animations and hotspots about halfway down on the website linked below:

Although I can see all the elements individually, I am intrigued by how they managed to put it all together. The precise positioning of the elements using percentages to 5 decimal places leads me to believe that some software was utilized to create both the SVGs and the layout. Do you have any insight into what software they may have used? It seems highly unlikely that they hand-coded the entire layout and calculated all the positioning manually.

Answer №1

To achieve the same functionality, you can utilize SVG with stroke-dasharray and stroke-dashoffset attributes manipulation through JavaScript animation timers. Typically, I prefer using D3.js for this kind of animation/SVG manipulation, but it can also be done purely in JavaScript. Here is an example on bl.ocks.org by Noah Veltman:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <style>
    path {
      fill: none;
      stroke: #d3008c;
      stroke-width: 2px;
    }

    #arrowhead {
      fill: #d3008c;
      stroke: none;
    }

  </style>
</head>
<body>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="960" height="500">
  <path d="M636.5,315c-0.4-18.7,1.9-27.9-5.3-35.9
  c-22.7-25-107.3-2.8-118.3,35.9c-7,24.4,20.6,37.2,16,71c-4,29.6-30.8,60.7-56.5,61.1c-30.8,0.4-32.9-43.8-81.7-70.2
  c-50.9-27.6-110.1-12.9-125.2-9.2c-66.1,16.4-82.2,56.9-109.2,47.3c-38-13.6-55.9-112.1-19.8-143.5c39-34,121.2,27.7,148.1-3.8
  c18-21.1,3.1-74.3-25.2-105.3c-31.1-34.1-70.1-32.4-105.3-76.3c-8.2-10.2-16.9-23.8-15.3-39.7c1.2-11.4,7.5-23.3,15.3-29
  c33.8-25,101.6,62.6,193.1,59.5c40.1-1.3,38.7-18.5,99.2-38.9c126.2-42.6,242.4-4.9,297.7,13c54.7,17.7,105.4,35,129.8,82.4
  c13,25.3,22.9,67.7,4.6,87c-11.6,12.3-25.1,5.1-46.6,20.6c-2.8,2-28.9,21.4-32.1,49.6c-3.1,27.4,18.7,35,29,70.2
  c8.8,30.1,8.5,77.8-18.3,99.2c-32.3,25.8-87,0.6-100-5.3c-69.6-32-67.2-88.4-73.3-109.2z"/>
    <defs>
      <path id="arrowhead" d="M7,0 L-7,-5 L-7,5 Z" />
    </defs>
</svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>

  var path = document.querySelector("path"),
      totalLength = path.getTotalLength(),
      group = totalLength / 20,
      start;

  var arrowheads = d3.select("svg").selectAll("use")
    .data(d3.range(20).map(function(d){ return d * group + 50; }))
    .enter()
    .append("use")
      .attr("xlink:href", "#arrowhead");

  path.style.strokeDasharray = "50," + (group - 50);

  requestAnimationFrame(update);

  function update(t) {
    if (!start) {
      start = t;
    }

    var offset = -group * ((t - start) % 900) / 900;

    path.style.strokeDashoffset = offset;

    arrowheads.attr("transform",function(d){

      var l = d - offset;

      if (l < 0) {
        l = totalLength + l;
      } else if (l > totalLength) {
        l -= totalLength;
      }

      var p = pointAtLength(l);
      return "translate(" + p + ") rotate( " + angleAtLength(l) + ")";
    });

    requestAnimationFrame(update);
  }

  function pointAtLength(l) {

    var xy = path.getPointAtLength(l);
    return [xy.x, xy.y];

  }

  // Approximate tangent
  function angleAtLength(l) {

    var a = pointAtLength(Math.max(l - 0.01,0)), // this could be slightly negative
        b = pointAtLength(l + 0.01); // browsers cap at total length

    return Math.atan2(b[1] - a[1], b[0] - a[0]) * 180 / Math.PI;

  }

</script>

Here is a representation of the <path> without animations:

path {
  fill: none;
  stroke: #d3008c;
  stroke-width: 2px;
}

#arrowhead {
  fill: #d3008c;
  stroke: none;
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="960" height="500">
  <path d="M636.5,315c-0.4-18.7,1.9-27.9-5.3-35.9
  c-22.7-25-107.3-2.8-118.3,35.9c-7,24.4,20.6,37.2,16,71c-4,29.6-30.8,60.7-56.5,61.1c-30.8,0.4-32.9-43.8-81.7-70.2
  c-50.9-27.6-110.1-12.9-125.2-9.2c-66.1,16.4-82.2,56.9-109.2,47.3c-38-13.6-55.9-112.1-19.8-143.5c39-34,121.2,27.7,148.1-3.8
  c18-21.1,3.1-74.3-25.2-105.3c-31.1-34.1-70.1-32.4-105.3-76.3c-8.2-10.2-16.9-23.8-15.3-39.7c1.2-11.4,7.5-23.3,15.3-29
  c-Content truncated-

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

``There seems to be a problem with navigating to a specific

I'm encountering an issue with this script // App.js ( shrink ) var controller = require('./controller'); app.get('/', controller.index); app.get('/home', controller.home); // /controller/index.js var meta = { ...

The Arrow notations don't seem to be functioning properly in Internet Explorer

Check out my code snippet in this JSFiddle link. It's working smoothly on Chrome and Mozilla, but encountering issues on IE due to arrow notations. The problem lies within the arrow notations that are not supported on IE platform. Here is the specifi ...

Using innovative Javascript capabilities for intricate CSS characteristics

As I dive into my JavaScript code that heavily manipulates the DOM, efficiency is key. I'm on the hunt for a native browser API that allows me to handle complex CSS attributes with ease. Performance matters to me, so using tools that are as native as ...

Is there an XML File Wrapper to Generate PDF Output?

Greetings Forum Members, I have been given the responsibility of creating a PDF file from multiple XML files. Has anyone come across an XML wrapper file before? This type of file would essentially contain a list of all the source XML file names in a spec ...

What is the best way to dynamically center text within a circle shape?

My dilemma lies in the design of a circular div that contains random text. While I am able to manually align the text inside the circle for static content, I seek a dynamic solution. Is there an automated way to adjust the size of the circle based on the t ...

Utilized JavaScript and CSS class to create a toggleable button

I am attempting to implement a toggle script on a button by using a CSS class. Issue: When I click on button2, it automatically selects button3, which is incorrect. Only one button should be active at a time upon clicking. function togbtn9() { $("#b ...

Exploring methods to retrieve data from an array in a Vue store through Getters

I am currently facing an issue where I am attempting to include an argument within getters in order to retrieve the ID of the permissions, but unfortunately it is not returning any results. ////STATE state: { permissions: [ {id: 1, name: 'Crea ...

React array fails to update upon modification

Hey there! I've created a component that takes an array of strings, combines them, and then renders a typing animation by wrapping each character in a span tag with toggling opacity from 0 to 1. I noticed an issue when switching the order of displaye ...

Building with bricks and mortar does not involve organizing visual content

I'm currently trying to organize some fairly large images using masonry, but the code below doesn't seem to be working. I'm using node.js with express and have installed the masonryjs package in an attempt to make it work, but that approach ...

How do you effectively select tabs that are enabled using jQuery UI?

Is there a way to retrieve all the tabs that are currently enabled while multiple tabs exist and some are disabled within a jquery ui tab interface? ...

What could be the reason my form inputs are not capturing any data?

I am currently working with React to build a form, but I am facing an issue. Whenever I try to type in the form fields, nothing seems to happen. Upon inspecting the state of each input in the React dev tools, I noticed that it is only capturing one letter ...

JavaScript does not allow the use of variables outside of functions

As someone diving into the world of Javascript after working extensively with server-side languages like PHP, I've noticed a peculiar issue. It seems that I am unable to access variables defined outside of a function from within the function itself. T ...

What is the best way to transform XML into a two-dimensional array using JavaScript?

I really need to store the array in a variable. Currently, I am utilizing .DataTable for pagination. However, it doesn't support tables generated from XML using JavaScript. Based on this source, I have to convert my XML into a 2D array. Below is the ...

In my chat application, I encountered the error message "Received an expression instead of an assignment or function call - no-unused-expressions"

While working on my React Chat app and trying to access my Firebase, I encountered the error message: "Expected an assignment or function call and instead saw an expression no-unused-expressions" The error seems to be related to the assignment of this.rem ...

What is the best way to convert Arabic language HTML into a PDF document on the client side?

Utilizing jsPDF and vue js, I successfully implemented a feature to export PDFs. However, I encountered an issue with Arabic characters not displaying properly. Can anyone provide assistance in resolving this problem? ...

Encountering an issue with importing external JavaScript files in the App.js file during React development

Currently, I am embarking on the development of a basic starter app that deals with SMTP anonymously in React. This project is primarily for educational purposes. Prior to diving into actual development work, I have decided to keep things simple and focus ...

Navigating the art of employing different fonts for a website

I am looking to incorporate the trainway font into my website, but I'm concerned that the user may not have it installed on their device. Is there a way to showcase text in a specific font without requiring the user to download and install it? Thank ...

Insert a new class within the container div

I am looking to insert a 'disabled' class within a parent div named 'anchorxx' https://i.sstatic.net/3KRMQ.png The disabled class div can be located anywhere within the anchorXX divs Is it achievable using jquery? I am unsure how to ...

What is the best way to create a sliding animation on a div that makes it disappear?

While I may not be an expert in animations, I have a question about sliding up the "gl_banner" div after a short delay and having the content below it move back to its original position. What CSS properties should I use for this animation? Should I use css ...

Utilizing URL-based conditions in Reactjs

Currently, I am working with Reactjs and utilizing the Next.js framework. My goal is to display different text depending on whether the URL contains "?id=pinned". How can I achieve this? Below is the snippet of my code located in [slug.js] return( ...