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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="1280"
   height="720"
   id="svg"
   version="1.1"
   inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
   sodipodi:docname="codepen.svg">
  <defs
     id="defs4">
    <linearGradient
       id="linearGradient138"
       spreadMethod="reflect"
       gradientTransform="matrix(-117.21479,0,0,117.21479,174.49799,448.04224)"
       gradientUnits="userSpaceOnUse"
       y2="0"
       x2="1"
       y1="0"
       x1="0">
      <stop
         id="stop134"
         offset="0"
         style="stop-opacity:1;stop-color:#008de9" />
      <stop
         id="stop136"
         offset="1"
         style="stop-opacity:1;stop-color:#00dede" />
    </linearGradient>
    <clipPath
       id="clipPath148-1"
       clipPathUnits="userSpaceOnUse">
      <path
         inkscape:connector-curvature="0"
         id="path146-12"
         d="M 0,500 H 500 V 0 H 0 Z" />
    </clipPath>
    <clipPath
       id="clipPath164-7"
       clipPathUnits="userSpaceOnUse">
      <path
         inkscape:connector-curvature="0"
         id="path162-8"
         d="M 0,500 H 500 V 0 H 0 Z" />
    </clipPath>
    <clipPath
       id="clipPath148-1-9"
       clipPathUnits="userSpaceOnUse">
      <path
         inkscape:connector-curvature="0"
         id="path146-12-4"
         d="M 0,500 H 500 V 0 H 0 Z" />
    </clipPath>
    <clipPath
       id="clipPath164-7-6"
       clipPathUnits="userSpaceOnUse">
      <path
         inkscape:connector-curvature="0"
         id="path162-8-9"
         d="M 0,500 H 500 V 0 H 0 Z" />
    </clipPath>
    <linearGradient
       inkscape:collect="always"
       xlink:href="#linearGradient138"
       id="linearGradient928"
       x1="13.341518"
       y1="334.30881"
       x2="756.82794"
       y2="334.30881"
       gradientUnits="userSpaceOnUse"
       spreadMethod="pad"
       gradientTransform="translate(0,0.60645294)" />
    <linearGradient
       inkscape:collect="always"
       xlink:href="#linearGradient138"
       id="linearGradient938"
       x1="29.108768"
       y1="334.91525"
       x2="97.029221"
       y2="334.91525"
       gradientUnits="userSpaceOnUse"
       spreadMethod="pad" />
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#000000"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="1"
     inkscape:pageshadow="2"
     inkscape:zoom="0.82449385"
     inkscape:cx="613.31822"
     inkscape:cy="457.72972"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     width="800px"
     inkscape:window-width="1920"
     inkscape:window-height="1017"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-332.36218)" />
  <g
     id="g942">
    <rect
       ry="13.8132"
       y="291.25211"
       x="10"
       height="87.326302"
       width="740"
       id="bck"
       style="opacity:1;fill:url(#linearGradient928);fill-opacity:1;stroke:none;stroke-width:7.55905533;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
    <rect
       ry="13.8132"
       y="227.57668"
       x="30"
       height="214.67717"
       width="65"
       id="slider"
       style="opacity:1;fill:url(#linearGradient938);fill-opacity:1;stroke:#000000;stroke-width:7.55905533;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
  </g>
</svg>

              
            
!

CSS

              
                html, body { margin:0; padding:0; overflow:hidden; background-color:black; }
svg { position:fixed; top:0; bottom:0; left:0; right:0; height:100%; width:100%}

              
            
!

JS

              
                var deviceJson = JSON.parse('{"current_value":35.0,"min_raw":15.0,"min_value":15.0,"max_raw":35.0,"max_value":35.0}');

function GetCalibratedValue(min_raw, max_raw, min_value, max_value, sensor) {
    var mnozioc = (max_value - min_value) / (max_raw - min_raw);
    return (sensor - min_raw) * mnozioc + min_value;
}


$(document).ready(function () {
      
    ////remove below
  var svg = Snap('#svg');
    svg.attr({
        viewBox: "0 0 1280 720",
        width: "100%",
        height: "100%"
    });
  //////////remove to here
  
  
    var s = Snap("#slider");
    var bck = Snap("#bck");
    var rightLimitPX = bck.node.getClientRects()[0].x + bck.node.getClientRects()[0].width;
    var leftLimitPX = bck.node.getClientRects()[0].x;
    var leftPX = s.node.getBoundingClientRect().x;
   

    var initPositionPX = parseInt(GetCalibratedValue(deviceJson.min_value, deviceJson.max_value, leftLimitPX, rightLimitPX, deviceJson.current_value));
    initPositionPX -= leftPX;
  
    TweenLite.to("#slider", 0.5, { x: initPositionPX, ease: Power1.easeInOut });


    var obj = Draggable.create("#slider", { type: "x", edgeResistance: 0.65, bounds: "#bck", lockAxis: true, throwProps: false });
  
});
              
            
!
999px

Console