Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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="https://kit.fontawesome.com/6873aa3c17.js" crossorigin="anonymous"></script>

<div class='card'>
  
  <span style="font-size: 2em; color: Green; opacity: .5; position: relative; top: 10px; left: 10px; cursor: pointer;">
    <i class="fas fa-leaf"></i></span>
  <span style="font-size: 2em; color: Orange; opacity: .5; position: relative; top: 10px; left: 215px; cursor: pointer;">
    <i class="fas fa-sign-out-alt"></i></span>
  <span style="font-size: 2em; color: Blue; opacity: .5; position: relative; top: 250px; left: -65px; cursor: pointer;">
    <i class="fas fa-rocket"></i></span>
  <span style="font-size: 2em; color: Red; opacity: .4; position: relative; top: 250px; left: 140px; cursor: pointer;">
    <i class="fas fa-sync"></i></span>
  
  <div id='thermostat' class="thermostat" onclick="void(0);">
    <div class="ring">
      <div class="bottom_overlay"></div>
    </div>

    <div class="control">
      
      <div class="temp_outside">
        <a id='temp-lower'>72</a>
        <a>-</a>
        <a id='temp-upper'>72</a><span class="deg">&deg;</span>
      </div>

      <div id='lower-indicator' class="indicator"></div>
      <div id='upper-indicator' class="indicator"></div>

      <div>
        <div class="temp_room"><a id='temp-room'>72</a><span class="deg">&deg;</span></div>
        <div class="room">Bedroom</div>
      </div>

    </div>
  
    <ul class="pie">
      <li class="section">
        <div id="upper-selector" class="selector" onclick="depressSelector(this.id)"></div>
      </li>
      <li class="section">
        <div id="lower-selector" class="selector" onclick="depressSelector(this.id)"></div>
      </li>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300);
 body {
	 background: white;
	 font-family: 'Open Sans', Helvetica, sans-serif;
	 -webkit-font-smoothing: antialiased;
	 -moz-osx-font-smoothing: grayscale;
}

.card {
  position: absolute;
  left: 20%;
  top: 20%;
  display: inline-block;
  width: 300px;
  height: 300px;
  z-index: -1;
  border: 1px solid orange;
  border-radius: 5px;
  /* box-shadow: 0px 0px 15px gray; */
}

 .ring {
	 position: absolute;
	 width: 180px;
	 height: 180px;
	 top: 10px;
	 left: 10px;
/* 	 background: linear-gradient(to right, blue 0%, red 100%); */
   background: linear-gradient(to right, white 0%, orange 100%);
	 border-radius: 50%;
	 box-shadow: inset 2px 4px 4px 0px rgba(0, 0, 0, 0.3);
}
 .bottom_overlay {
	 position: absolute;
	 width: 95px;
	 height: 95px;
	 top: 50%;
	 left: 50%;
	 background: white;
	 transform-origin: 0 0;
	 transform: rotate(45deg);
	 border-radius: 0 0 95px 0;
}
 .thermostat {
	 position: relative;
   display: inline-block;
	 width: 200px;
	 height: 200px;
	 top: 0;
	 left: 16%;
	 background: #f2f2f2;
	 border-radius: 50%;
	 border: 3px solid #F2F2F2;
}
 .thermostat .control {
	 position: absolute;
	 z-index: 5;
	 width: 130px;
	 height: 130px;
	 top: 35px;
	 left: 35px;
	 background: #fff;
	 border-radius: 50%;
	 box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.2);
}
 .thermostat .control .indicator {
	 position: absolute;
	 width: 2px;
	 height: 17px;
	 left: 50%;
	 top: 0;
	 background: gray;
	 transform-origin: 0 65px;
	 transition: all 0.5s ease-in-out;
}
 .thermostat .control .temp_outside {
	 position: absolute;
	 top: 18px;
	 left: 6px;
	 right: 0;
	 text-align: center;
	 font-weight: 300;
	 font-size: 12px;
}
 .thermostat .control .temp_room {
	 position: absolute;
	 top: 34px;
	 left: 0;
	 right: 0;
	 text-align: center;
	 font-weight: 400;
	 font-size: 60px;
	 line-height: 60px;
	 color: gray;
	 letter-spacing: -4px;
	 padding-right: 7px;
	 opacity: 1;
	 transform: translateX(0);
	 transition: all 0.5s ease-in-out;
}
 .thermostat .control .temp_room .deg {
	 position: absolute;
	 top: 0;
	 right: 30px;
	 font-size: 20px;
	 line-height: 34px;
	 padding: 0 0 0 7px;
}
 .thermostat .room {
	 position: absolute;
	 bottom: 18px;
	 left: 0;
	 right: 0;
	 text-align: center;
	 font-weight: 300;
	 font-size: 12px;
	 opacity: 1;
	 transform: translateX(0);
	 transition: all 0.5s ease-in-out;
}
 .pie {
	 z-index: -1;
	 position: inherit;
	 top: -20%;
	 left: -12.5%;
	 padding: 0;
	 width: 250px;
	 height: 250px;
	 border-radius: 50%;
	 list-style: none;
	 overflow: hidden;
}
 .pie .section {
	 overflow: hidden;
	 position: absolute;
	 top: -50%;
	 right: -50%;
	 width: 100%;
	 height: 100%;
	 transform-origin: 0% 100%;
}
 .pie .section:nth-child(1) {
	 transform: rotate(30deg) skewY(210deg);
	 background: #e3e3e3;
}
 .pie .section:nth-child(2) {
	 transform: rotate(210deg) skewY(210deg);
	 background: #e3e3e3;
}
 .pie .section:nth-child(1):hover {
	 background: #ffd796;
   cursor: pointer;
}
 .pie .section:nth-child(2):hover {
	 background: #ffd796;
   cursor: pointer;
}
 .pie .selector {
	 position: absolute;
	 left: -100%;
	 width: 200%;
	 height: 200%;
}
 
.selected {
  background: #ffd796;
}
              
            
!

JS

              
                window.addEventListener('scroll', function noScroll() {
  window.scrollTo(0, 0);
});

thermostat = document.getElementById('thermostat');
lowerIndicator = document.getElementById('lower-indicator');
upperIndicator = document.getElementById('upper-indicator');
lowerSelector = document.getElementById('lower-selector');
upperSelector = document.getElementById('upper-selector');
lowerTemperature = document.getElementById('temp-lower');
upperTemperature = document.getElementById('temp-upper');
roomTemperature = document.getElementById('temp-room');

const draggableItem = document.getElementsByClassName( 'card' )[0];
let currentlyDragging = null;
draggableItem.setAttribute( 'draggable', true );
draggableItem.ondragstart = function( ev ) {
  ev.dataTransfer.effectAllowed = 'move';
  ev.dataTransfer.setData( 'text/html', this.innerHTML )
  currentlyDragging = ev.target;
  console.log('Currently Dragging: ' + currentlyDragging.id);
}

let maxTemp = 99;
let minTemp = 45;
let minDeg = -135;
let maxDeg = 135;

let leftSelectorOn = false;
let rightSelectorOn = false;

// Show selectors as depressed
function depressSelector(id) {
  if (id == "lower-selector") {
    leftSelectorOn = !leftSelectorOn
    document.getElementById(id).classList.toggle('selected');
    if (rightSelectorOn) {
      rightSelectorOn = !rightSelectorOn
      document.getElementById("upper-selector").classList.toggle('selected');
    }
  };
  if (id == "upper-selector") {
    rightSelectorOn = !rightSelectorOn;
    if (leftSelectorOn) {
      leftSelectorOn = !leftSelectorOn;
      document.getElementById("lower-selector").classList.toggle('selected');
    }
    document.getElementById(id).classList.toggle('selected');
  };
}

var lowerTemp = parseInt(lowerTemperature.textContent);
var upperTemp = parseInt(upperTemperature.textContent);

var delta = (maxDeg - minDeg)/(maxTemp - minTemp);

// var lowerScrollPos = delta * lowerTemp % 360;
// var upperScrollPos = delta * upperTemp % 360;

var lowerScrollPos = 0;
var upperScrollPos = 0;

lowerIndicator.style.transform = `rotate(${lowerScrollPos}deg)`;
upperIndicator.style.transform = `rotate(${upperScrollPos}deg)`;

thermostat.addEventListener('wheel', function(e) {
  //console.log(e);  
  
  // HANDLE LOWER TEMPERATURE SELECTOR
  if (leftSelectorOn && !rightSelectorOn) {
    
    // Scrolling Up
    if (e.deltaY < 0) {
      lowerTemp += 1;
      if (lowerScrollPos <= maxDeg) {lowerScrollPos += delta};
              
      // Make indicators inelastic
      if (lowerTemp > upperTemp) {
        upperTemp = lowerTemp;
        
        if (upperScrollPos <= maxDeg) {upperScrollPos += delta};
      }
    } 
    
    // Scrolling Down
    else if (e.deltaY > 0) {
      lowerTemp -= 1;
      if (lowerScrollPos >= minDeg) {lowerScrollPos -= delta};    
    }
  }
  
  // HANDLE UPPER TEMPERATURE SELECTOR
  if (rightSelectorOn && !leftSelectorOn) {
    
    // Scrolling Up
    if (e.deltaY < 0) {
      upperTemp += 1;
      if (upperScrollPos <= maxDeg) {upperScrollPos += delta};    
    } 
    
    // Scrolling Down
    else if (e.deltaY > 0) {
      upperTemp -= 1;
      if (upperScrollPos >= minDeg) {upperScrollPos -= delta};
      
      // Make indicators inelastic
      if (upperTemp < lowerTemp) {
        lowerTemp = upperTemp;
        if (lowerScrollPos >= minDeg) {lowerScrollPos -= delta};
      }
    } 
  }
   
  // GLOBAL RULES: Keep Temperatures within Bounds
  if (lowerTemp >= maxTemp) { 
    lowerTemp = maxTemp;
  }
  if (lowerTemp <= minTemp) {
    lowerTemp = minTemp;
  } 
  if (upperTemp >= maxTemp) { 
    upperTemp = maxTemp;
  } 
  if (upperTemp <= minTemp) {
    upperTemp = minTemp;
  } 
  
  console.log(lowerScrollPos);
  console.log(upperScrollPos);
  lowerTemperature.innerHTML = lowerTemp;
  upperTemperature.innerHTML = upperTemp;
  lowerIndicator.style.transform = `rotate(${lowerScrollPos}deg)`;
  upperIndicator.style.transform = `rotate(${upperScrollPos}deg)`;
  
  // Handle Heating/Cooling Border Indication
  if (parseInt(roomTemperature.textContent) < lowerTemp) {
    thermostat.style.border = "2px solid red" // Heat
  } else if (parseInt(roomTemperature.textContent) > upperTemp) {
    thermostat.style.border = "2px solid blue" // Cool
  } else {
    thermostat.style.border = "2px solid #F2F2F2" // In-range
  }
    
});


              
            
!
999px

Console