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

              
                <body id='body'></body>
              
            
!

CSS

              
                #face{
  fill:#aaeeff;
  fill-opacity:1;
  fill-rule:evenodd;
  stroke:#000000;
  stroke-width:0.5px;
  stroke-linecap:butt;
  stroke-linejoin:miter;
  stroke-miterlimit:4;
}
svg{
  position: absolute;
  top: -100px;
  width: 70%;
}

              
            
!

JS

              
                
TweenMax.to('.green',2,{x:300, yoyo:true})

class Trap extends React.Component{
  constructor(props){
    super(props);
    this.state={count:12};
  };
  
  componentDidMount(){
    const count=this.state.count;
    repCount(count);
  }
  
  render(){
    return(
      <div>
        <svg viewBox="0 0 171.97917 158.75001">
           <g id="face">
            <path id="tl_1"
            d="M 54.459339,79.369672 C 52.279189,75.580862 48.985237,48.170287 51.101887,44.487317 L 86.047787,79.433222 C 74.427377,79.412022 66.079749,79.390872 54.459339,79.369672 Z"
            />
            <path id="tl_2"
            d="M 86.110978,49.745128 C 82.322168,47.564978 54.784861,42.370667 51.101888,44.487317 L 86.047787,79.433222 Z"
            />
            <path id="tr_1"
            d="M 86.110978,49.745128 C 89.899788,47.564978 117.20489,42.370667 120.86669,44.487317 L 85.941957,79.433222 Z"
            />
            <path id="tr_2"
            d="M 117.78382,79.496413 C 119.96397,75.707603 122.9834,48.170287 120.86672,44.487317 L 85.941987,79.433222 C 97.562397,79.412022 106.14224,79.517613 117.78382,79.496413 Z"
            />
            <path id="br_1"
            d="M 117.78382,79.496413 C 119.96397,83.285213 122.98343,110.59037 120.86675,114.25216 L 85.942017,79.327422 C 97.562427,79.327422 106.14224,79.475313 117.78382,79.496413 Z"
            />
            <path id="br_2"
            d="M 85.984317,109.649 C 89.773127,111.82914 117.20492,116.36884 120.86672,114.25216 L 85.941987,79.327422 Z"
            />
            <path id="bl_1"
            d="M 85.984317,109.649 C 82.195507,111.82915 54.784861,116.36882 51.101888,114.25213 L 86.047787,79.327372 Z"
            />
            <path id="bl_2"
            d="M 54.459339,79.369672 C 52.279189,83.158472 48.985237,110.59032 51.101887,114.25212 L 86.047787,79.327372 C 74.427377,79.327372 66.07975,79.348572 54.459339,79.369672 Z"
            />
          </g>
        </svg>
      </div>
    );
  }
}
ReactDOM.render(<Trap />,document.getElementById('body'));

function vertAni(){
  const SPD=.35;
  let tl=new TimelineMax({yoyo:true,ease:Power0.easeNone});
  tl
    .to('#tl_1',SPD,{attr:{d:"M 51.165387,79.369722 C 48.985237,75.580912 38.343235,51.46424 40.459885,47.78127 L 85.941957,60.936408 C 73.054642,68.263257 63.799321,72.296254 51.165387,79.369722 Z"}},0)
    .to('#tl_2',SPD,{attr:{d:"M 85.984287,44.550817 C 82.195477,42.370667 44.142858,45.66462 40.459885,47.78127 L 85.941957,60.936408 Z"}},0)
    .to('#tr_1',SPD,{attr:{d:"M 85.984287,44.550817 C 89.773097,42.370667 121.76578,45.411239 125.42758,47.527889 L 85.941957,60.936408 Z"}},0)
    .to('#tr_2',SPD,{attr:{d:"M 120.82442,79.369722 C 123.00457,75.580912 127.54426,51.210859 125.42758,47.527889 L 85.941957,60.936408 C 98.829272,67.503114 104.11519,70.522586 120.82439,79.369722 Z"}},0)
    .to('#br_1',SPD,{attr:{d:"M 120.82445,79.369762 C 123.0046,83.158562 129.82472,110.08361 127.70804,113.7454 L 86.047787,93.516709 C 97.668197,87.942327 106.90241,84.669623 120.82442,79.369722 Z"}},0)
    .to('#br_2',SPD,{attr:{d:"M 85.984317,114.20986 C 89.773127,116.39 124.04624,115.86208 127.70804,113.7454 L 86.047787,93.516709 Z"}},0)
    .to('#bl_1',SPD,{attr:{d:"M 85.984287,114.20983 C 82.195477,116.38998 48.957097,114.84852 45.274124,112.73183 L 86.047787,93.516709 Z"}},0)
    .to('#bl_2',SPD,{attr:{d:"M 51.165387,79.369712 C 48.985237,83.158512 43.157474,109.07003 45.274124,112.73183 L 86.047787,93.516709 C 74.427377,89.462613 63.799321,83.90943 51.165386,79.369672 Z"}},0)
  ;
  return tl;
}
function horiAni(){
  const SPD=.35;
  let tl=new TimelineMax({yoyo:true,ease:Power0.easeNone});
  tl
    .to('#tl_1',SPD,{attr:{d:"M 51.234325,79.190505 C 49.054175,75.401695 43.431048,50.678631 45.547698,46.995661 L 68.489379,79.254055 C 56.868969,79.232855 62.854735,79.211705 51.234325,79.190505 Z"}},0)
    .to('#tl_2',SPD,{attr:{d:"M 86.290145,53.686812 C 82.501335,51.506662 49.230671,44.879011 45.547698,46.995661 L 68.489379,79.254055 Z"}},0)
    .to('#tr_1',SPD,{attr:{d:"M 86.290145,53.686812 C 90.078955,51.506662 121.32577,45.058179 124.98757,47.174829 L 107.44205,79.074887 Z"}},0)
    .to('#tr_2',SPD,{attr:{d:"M 121.00883,79.138078 C 123.18898,75.349268 127.10425,50.857799 124.98757,47.174829 L 107.44205,79.074887 C 119.06246,79.053687 109.36725,79.159278 121.00883,79.138078 Z"}},0)
    .to('#br_1',SPD,{attr:{d:"M 121.00883,79.138078 C 123.18898,82.926878 128.89592,108.2612 126.77924,111.92299 L 107.44205,79.074887 C 119.06246,79.074887 109.36725,79.116978 121.00883,79.138078 Z"}},0)
    .to('#br_2',SPD,{attr:{d:"M 85.80515,106.06565 C 89.59396,108.24579 123.11744,114.03967 126.77924,111.92299 L 107.44205,79.074887 Z"}},0)
    .to('#bl_1',SPD,{attr:{d:"M 85.80515,106.06565 C 82.01634,108.2458 49.947339,112.96462 46.264366,110.84793 L 68.489379,79.254055 Z"}},0)
    .to('#bl_2',SPD,{attr:{d:"M 51.234325,79.190505 C 49.054175,82.979305 44.147716,107.18613 46.264366,110.84793 L 68.489379,79.254055 C 56.868969,79.254055 62.854736,79.169405 51.234325,79.190505 Z"}},0)
  ;
  return tl;
}
function repCount(rep) {
    let tl = new TimelineMax();
    for (let i = 0; i < rep; i++) {
        if (i % 2 === 0) { tl.add(vertAni(), i); };
        if (i % 2 === 1) { tl.add(horiAni(), i); };
    }
    return tl;
}

              
            
!
999px

Console