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

              
                <html lang="de">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>SVG Draggable Rangeslider</title>

  <!--Fonts-->
  <link href='//fonts.googleapis.com/css?family=Signika+Negative:400,300,600,700' rel='stylesheet' type='text/css'>
  <!-- Javascript -->
  <script src="js/TweenMax.min.js"></script>
  <script src="js/Draggable.min.js"></script>

</head>

<body style="margin-left: 20px; font-family: 'Signika Negative', sans-serif;">
  <h1>SVG Draggable Rangeslider</h1>

  <!--<svg viewbox="0 0 890 100">-->
  <svg viewbox="0 0 890 100" style="background: #333; border: 1px dotted #000; width: 890; height:100">
    <defs>
      <linearGradient id="blackGR" x1="0.49998" y1="0.00812" x2="0.49998" y2="0.96125">
        <stop offset="0" stop-color="#545252"></stop>
        <stop offset="1" stop-color="#3D3D3D"></stop>
      </linearGradient>
    </defs>

    <g id="range" transform="translate (20 35)">
      <rect class="rangeBG" y="1" x="20" fill="#666" width="800" height="24"></rect>
      <rect class="T_Range" fill="url(#blackGR)" x="20" y="5" width="16" height="16" rx="6" ry="6"></rect>

      <!-- <rect class="left_bg" y="5" x="20" fill="#000" fill-opacity="0.5" width="16" height="16" rx="6" ry="6" /> -->
      <!-- <rect class="drag" y="9" x="24" fill="#fff" fill-opacity="0.5" width="8" height="8" rx="2" ry="2" /> -->

      <rect id="one" class="drag" y="9" x="24" fill="#fff" fill-opacity="0.8" width="8" height="8" rx="2" ry="2" paint-order="stroke fill markers"
            stroke-width="8" stroke-opacity="0.5" stroke="#000"></rect>
      <rect id="two" class="drag" y="9" x="24" fill="#fff" fill-opacity="0.8" width="8" height="8" rx="2" ry="2" paint-order="stroke fill markers" 
            stroke-width="8" stroke-opacity="0.5" stroke="#000"></rect>

    </g>

  </svg>

  </body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                    var minrange = 55;
    var maxrange = 200;

    TR_Draggable = Draggable.create (".T_Range", {
      type: "x",
      onDrag: function () {
        var x1 = Draggables[0].x;
        var x2 = Draggables[1].x;

        TweenMax.set(document.getElementById("one"), { x: this.x });

        if (x1 < x2) {
          TR_Draggable.applyBounds ({ minX: 0, maxX: 784 - (x2 - x1) });
          TweenMax.set(document.getElementById("two"), { x: this.x + x2 - x1 });
        }
        else {
          TR_Draggable.applyBounds ({ minX: 0, maxX: 784 - (x1 - x2) });
          TweenMax.set(document.getElementById("two"), { x: this.x + x1 - x2 });
        };
        TR_Draggable.update();
      }
    })[0];    // [0] ???

    Draggables = Draggable.create (".drag", {
      type: "x",
      bounds: { minX: 0, maxX: 784, }, // full Range
      onDrag: function () {
    
        var x1 = Draggables[0].x;
        var x2 = Draggables[1].x;

        if (x1 < x2) {
          TweenMax.set ('.T_Range', { x: x1, width: x2 - x1 + 16 });
        }
        else {
          TweenMax.set ('.T_Range', { x: x2, width: x1 - x2 + 16 });
        };
        Draggables[0].update();
        Draggables[1].update();
      }
    });

    function initSlider () {
        TweenMax.set ('.T_Range', { x: minrange, width: maxrange - minrange })
        TweenMax.set (Draggables[0].target, { x: minrange, onUpdate: Draggables[0].update, onUpdateScope: Draggables[0] });
        TweenMax.set (Draggables[1].target, { x: maxrange - 16, onUpdate: Draggables[1].update, onUpdateScope: Draggables[1] });
    }
    initSlider ();

    Draggable.get (document.getElementById ("one")).vars.cursor = "e-resize";
    Draggable.get (document.getElementById ("two")).vars.cursor = "e-resize";
  /*That'll affect the cursor the next time the user interacts with the element - it's not for immediately changing the cursor. */
              
            
!
999px

Console