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

              
                <h1>Rect width animation issue</h1>

<p>The example width the green border works with "scaleX:value", however the stroke width is affected when scaling, which is what I don't want, also, the width needs to be specified as a percentage which also is not ideal for my purposes.</p>

<div class="demo1">
  <svg version="1.1" id="device" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 600 300" enable-background="new 0 0 600 300" xml:space="preserve" style="overflow:visible;">
    <rect id="rect1" x="110" y="35" fill="gray" stroke="green" stroke-width="8" stroke-miterlimit="10" width="380px" height="230"/>
</svg>
</div>

<p>The example with the red border uses "width:value", however the issue is SVG uses values without the apended "px". If you inspect the the rect element with the ID of "rect2" you will notice the CSS animation being applied to it, but it is trying to animate 'style="width:190px"'.</p>
<div class="demo2">
  <svg version="1.1" id="device" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 600 300" enable-background="new 0 0 600 300" xml:space="preserve" style="overflow:visible;">
    <rect id="rect2" x="110" y="35" fill="gray" stroke="red" stroke-width="8" stroke-miterlimit="10" width="380px" height="230"/>
</svg>
</div>
              
            
!

CSS

              
                body {
  font-family:sans-serif;
}

.demo1,
.demo2 {
  width:600px;
  height:300px;
  background-color:white;
}


h1 {
  margin: 5px 0;
}
p {
  max-width:600px;
}
              
            
!

JS

              
                var demo1 = new TimelineMax({repeat:-1, repeatDelay:0, yoyo:true});

demo1.to("#rect1", 1, {scaleX:0.5, transformOrigin:"50% 50%"});

var demo2 = new TimelineMax({repeat:-1, repeatDelay:0, yoyo:true});

demo2.to("#rect2", 1, {attr:{width:190}, transformOrigin:"50% 50%"});
              
            
!
999px

Console