cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <svg width="400" height="400" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
  <g id="sea">
        <rect id="black" fill="#000103" width="400" height="200"/>
        <rect id="grey" fill="#E3E1DD" y="200" width="400" height="200"/>
        <g id="fish" fill="#000103">
          <path d="M84 316c0-64.065 51.935-116 116-116s116 51.935 116 116H84zm84.5-53c8.56 0 15.5-6.94 15.5-15.5 0-8.56-6.94-15.5-15.5-15.5-8.56 0-15.5 6.94-15.5 15.5 0 8.56 6.94 15.5 15.5 15.5z" id="head"/>
          <path d="M173.2 247.057l11.45-11.45-4.95-4.95-11.45 11.45-11.45-11.45-4.95 4.95 11.45 11.45-11.45 11.45 4.95 4.95 11.45-11.45 11.45 11.45 4.95-4.95-11.45-11.45zM84.004 316c0-64.065 51.935-116 116-116s116 51.935 116 116c0 .334 0 .667-.004 1v-1H84.004z" id="dead"/>
          <g id="tail">
            <path d="M200.766 308.555v78.45c-31.01 29.084-88.892 31.202-89 30.89 45.233-36.728 74.9-73.175 89-109.34zm0 0c14.1 36.165 43.767 72.612 89 109.34-.108.312-57.99-1.806-89-30.89v-78.45z" id="Combined-Shape"/>
          </g>
        </g>
      </g>
</svg>
            
          
!
            
              const head = $("#head");
const tail = $("#tail");
const fish = $("#fish");

function getRotateAnimation(target, arr) {
  let rotateTimeline = new TimelineMax();
  for (let i = 0, l = arr.length; i < l; i++) {
    rotateTimeline.to(
      target,
      0.2,
      { rotation: arr[i] },
      `fish+=${0.2 * (i + 1)}`
    );
  }
  return rotateTimeline
}

let tl = new TimelineMax({ repeat: -1, repeatDelay: 0.5 });
var gtl = new TimelineMax();
tl
  .add("fish")
  .set([head, tail], { transformOrigin: "top center" })
  .fromTo(
    fish,
    2,
    { y: 200, autoAlpha: 1 },
    {
      ease: CustomEase.create(
        "custom",
        "M0,0 C0.083,0.294 0.083,0.64 0.41,0.64 0.984,0.64 0.752,1 1,1"
      ),
      y: -116
    }
  )
  .add(getRotateAnimation(head, [5, -5, 4, -4, 3, -3, 2, -2, 1, 0]), "fish")
  .add(getRotateAnimation(tail, [15, -10, 10, -8, 6, -6, 5, -5, 3, 0]), "fish")
  .set(head, { morphSVG: "#dead", fill: "#E3E1DD" }, "fish+=1.5")
  .add("up")
  .set(tail, { fill: "#E3E1DD" }, "up+=.2")
  .to(fish, 1, { y: -420, ease: Expo.easeOut }, "up+=.2")
            
          
!
999px
Loading ..................

Console