API Reference

The configurator expects messages in the following format:

const message = {
  data: {
    method: string,
    parameters: {},
  },
  type: "colormass",
};

Sending a message can be done as follows:

window.onload = () => {
  cmConfigurator = document.getElementById("cmConfigurator").contentWindow;
  cmConfigurator.postMessage(message, "https://configurator.colormass.com");
};

Events

In order to receive events from the iframe window, you have to initialize an event listener on the main window as follows:

window.onload = () => {
    window.addEventListener("message", receiveMessage, false);
}

function receiveMessage(message) {
    if (message.origin !== "https://configurator.colormass.com" ||
        message.data.type !== "colormass") return;
    const data = message.data.data;
    const methodName = data.method;
    const parameters = data.parameters;
    // Handle event based on the method's name and parameters
}

Last updated