Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="//vto-advanced-integration-api.fittingbox.com/index.js" type="text/javascript"></script>

<div class="wrapper">
  <div>
    <button onclick="fitmixInstance.setFrame('8053672909258')">Sample frame 1</button>
    <button onclick="fitmixInstance.setFrame('8056597233958')">Sample frame 2</button>
  </div>
  <div>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Brown')">Sample Brown Material</button>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Black')">Sample Black Material</button>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Purple')">Sample Purple Material</button>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Grey')">Sample Grey Material</button>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Blue')">Sample Blue Material</button>
  </div>
  <div>
    <button onclick="fitmixInstance.setLensMaterial('Sample_Photochromic')">Sample Photochromic Material</button>
  <label for="exposure">Photochromic - Exposure</label>
  <input type="range" id="exposure" name="exposure" min="0" max="100" />
  </div>
  
  <button onclick="openVto()">User action to start the VTO experience</button>
  <button onclick="stopVto()">User action to stop the VTO experience</button>  

  <div id="fitmix-container"></div>
</div>
              
            
!

CSS

              
                html, body {
  margin: 0;
}

.wrapper {
  --padding: 0.5rem;
  height: calc(100vh - var(--padding) * 2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: var(--padding);
}

#fitmix-container {
  width: min(500px, 90vw);
  flex: 1;
  display:none;
}

              
            
!

JS

              
                var params = { 
  apiKey: 'TBVAcXitApiZPVH791yxdHbAc8AKzBwtCnjtv6Xn',
  frame: '8053672909258',
  onStopVto: hide,
  
  // Used to display the embedded native "toolbar"
  /*  materials: {
    materials: [
      {
        name: 'Sample_Brown',
        image: 'https://picsum.photos/32?random=1'
      },
      {
        name: 'Sample_Green',
        image: 'https://picsum.photos/32?random=2'
      },
      {
        name: 'Sample_Black',
        image: 'https://picsum.photos/32?random=3'
      },
      {
        name: 'Sample_Purple',
        image: 'https://picsum.photos/32?random=4'
      },
      {
        name: 'Sample_Grey',
        image: 'https://picsum.photos/32?random=5'
      },
      {
        name: 'Sample_Blue',
        image: 'https://picsum.photos/32?random=6'
      }
    ]
  }*/
};

window.onload = function() {  
  window.fitmixInstance = FitMix.createWidget('fitmix-container', params, function() {});
}

const fitmix = document.getElementById("fitmix-container")

function hide(){
  fitmix.style.display= 'none';
}

function show(){
  fitmix.style.display= 'block';
}

function openVto(){
  fitmixInstance.startVto('live')
  show()
}

function stopVto(){
  fitmixInstance.stopVto()
}

var exposureInput = document.getElementById("exposure");
exposureInput.addEventListener("change", function() {
  fitmixInstance.setExposureLevel(Number(exposureInput.value));
}, false);
              
            
!
999px

Console