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

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                    //////////////xxAPI.functions.XXRSLIDER2 = function( oarg ) {
    //////////////
    var rtMin = 0;      //deg
    var rtMax = 270;    //deg
    var rtStep_p = 5; //0..100%
    var rtTicks = 2;    // 1: no Ticks, 2: 10 . 20 . 30, 3: 10 . . 20 . . 30
    var rtStep_g = calcXp2X(rtStep_p,rtMax-rtMin); // in Deg
    var rtStartV_p = 60; // 0..100%
    var rtStartV_g = Math.round(calcXp2X(rtStartV_p,rtMax-rtMin) - calcXp2X(rtStartV_p,rtMax-rtMin)%rtStep_g);  //deg
    rtStartV_p = Math.round(rtStartV_p - rtStartV_p%rtStep_p); // 0..100%
    var rtWidth  = '285px';
    var rtHeight = '218.7px';
    var rtColor =  '#ff0754';

    var _htmlSVG = 
      '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" ' + 
      'xmlns:xlink="http://www.w3.org/1999/xlink" ' + 
      'xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" ' +
      'x="0px" y="0px" width="284.1px" height="218.7px" ' + 
      'viewBox="0 0 284.1 218.7" enable-background="new 0 0 284.1 218.7" ' + 
      '<xml:></xml:>space="preserve"> ' +
      '<defs></defs> ' +
      '<path id="outline" fill="none" stroke="#FF0754" stroke-width="4" stroke-miterlimit="10" ' + 
      'd="M209.8,184.7l47.6,31.2c13.7-21.3,21.6-46.7,21.6-73.9c0-75.7-61.3-137-137-137S5,66.3,5,142c0,27.2,7.9,52.6,21.6,73.9l48-30.8"/> ' +
      '<path id="dialline" fill="none" stroke="#FF0754" stroke-width="60" stroke-miterlimit="10" ' +
      'd="M49.4,201.2C38.4,184,32,163.7,32,141.8c0-60.8,49.2-110,110-110s110,49.2,110,110c0,21.9-6.4,42.2-17.4,59.4"/> ' +
      '<path id="dial-line-bg" fill="none" stroke="#ecf0f1" stroke-width="60" stroke-miterlimit="10" ' +
      'd="M49.4,201.2C38.4,184,32,163.7,32,141.8c0-60.8,49.2-110,110-110s110,49.2,110,110c0,21.9-6.4,42.2-17.4,59.4"/> ' +
      '</svg>';

    /////////////////////  
    init_rslider2();  // OHNE RSLIDER2
    initSVG();        // MIT RSLIDER2
    ////////////////////
    function init_rslider2(){
      xx_startObject = document.createElement('div');
      document.body.appendChild(xx_startObject);
      xx_nullObject = document.createElement('div');
      xx_nullObject.className = 'null-object';
      xx_startObject.appendChild(xx_nullObject);
      xx_dialValue = document.createElement('div');
      xx_dialValue.className = 'dial-value';
      xx_dialValue.innerHTML = rtStartV_p;
      xx_startObject.appendChild(xx_dialValue);
      xx_svgNode = document.createElement('svg');
      xx_svgNode.className = 'svg-node';
      xx_svgNode.innerHTML = _htmlSVG;
      xx_startObject.appendChild(xx_svgNode);
      xx_container = document.createElement('div');
      xx_container.className = 'container';
      xx_startObject.appendChild(xx_container);
      TweenMax.set(document.body, {
        backgroundColor: '#181A19',
        userSelect:'none'
      });
      TweenMax.set([xx_svgNode], {
        position:'absolute',
        left:'50%',
        top:'50%',
        xPercent:-50,
        yPercent:-50
      });
      TweenMax.set(xx_container, {
        rotation:rtStartV_g,   
        width:rtWidth,   /*'285px',*/
        height:rtHeight, /*'218.7px',*/
        backgroundSize: '100% auto'
      });
      TweenMax.set(xx_dialValue, {
        color:rtColor, /* '#ecf0f1',*/
        fontSize:'54pt',
        fontFamily:'Oswald, Arial, Helvetica, sans-serif',
        textAlign:'center',
        marginTop:'20px'
      });
      TweenMax.set([xx_container, xx_dialValue], {
        position:'absolute',
        left:'50%',
        top:'50%',
        xPercent:-50,
        yPercent:-50
      });
      //  TweenMax.set(xx_svgNode, {
      //    backgroundImage: 'url(knob.svg)',
      //    backgroundSize: '100% auto'
      //  });
      TweenMax.set(xx_nullObject, {
        position:'absolute',
        x:0
      });
    } // init_rslider2()
    function initSVG(){  
      //$('#dial-line-bg').waitUntilExists(function(){
        xx_dialLineBg = document.getElementById('dial-line-bg'); //SVG
        TweenMax.set(xx_dialLineBg, {
          position:'absolute',
          alpha:0.1
        });
      //});
      //$('#dialline').waitUntilExists(function(){
        xx_dialLine   = document.getElementById('dialline');    //
        TweenMax.set(xx_dialLine, {
          stroke:rtColor,   /*"#FF0754"*/
          drawSVG:rtStartV_p + '%',
          alpha:0.5
        });
      //});
      //$('#outline').waitUntilExists(function(){
        xx_outline    = document.getElementById('outline');     //
        TweenMax.set(xx_outline, {
          stroke:rtColor   /*"#FF0754"*/
        });  
        // });
        // $('#outline').waitUntilExists(function(){
        xx_myDraggable = Draggable.create(xx_container, {
          //trigger:container,
          bounds:{maxRotation:rtMax, minRotation:0},
          type:'rotation',
          onPress:function(e){
            var rad = Math.atan2(e.layerY, e.layerX);
            // console.log(RadiansToDegrees(rad))
            var cX = e.layerX + (285/2);
            // cX = rtRound(cX,rtStep_p);
            var cPercent = (cX);
            //console.log(cPercent)
            TweenMax.to(xx_container, 1, {
              rotation:cPercent,
              onUpdate:dragUpdate
            })
          },
          throwProps:true,
          onDrag:dragUpdate
          //onThrowUpdate:dragUpdate,
          //snap:function(endValue){
          //  // Snapping
          //  return rtRound(endValue, rtStep_g);
          //}
        }) // Draggable.create
        // set start rotation
        //TweenMax.set(xx_container, {rotation: rtStartV_g});
        //xx_myDraggable.update();
      //}); // waitUntilExists
    } // initSVG() 
    //////////////

    function dragUpdate(){
      var percent = min0maxB(calcX2Xp(xx_container._gsTransform.rotation, rtMax-rtMin),100);
      TweenMax.set(xx_dialLine, {
        drawSVG:percent + '%'
      });
      percent = Math.round(rtRound(percent, calcX2Xp(rtStep_g,360)));
      xx_dialValue.innerHTML = percent;
      // console.log(percent)
    } // dragUpdate()
    function rtRound(_rt, _rtStep_g){
      return Math.round(_rt/_rtStep_g) * _rtStep_g // 0 decimals
    }
    function RadiansToDegrees(valRad){
      return (360/(2*Math.PI)*valRad) - 45;
    }
    function calcX2Xp(X,B){
      return Math.round(X/B*100)
    }
    function calcXp2X(Xp,B){
      return Math.round(Xp/100*B)
    }
    function min0maxB(X, B){
      return (X>B) ? B : (X<0) ? 0 : X
    }
              
            
!
999px

Console