<section id="waapi-transform-ordering-3" class="animate-things-wrapper-b">
    <div id="mains">
        <div id="boxContainerA">
            <div data-translate="">
                <div data-rotate="">
                    <div data-scale="">
                        <div class="box">
                            Translate -> Rotate -> Scale
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div id="boxContainerB">
            <div data-scale="">
                <div data-translate="">
                    <div data-rotate="">
                        <div class="box">
                            Scale -> Translate -> Rotate
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="ghosts">
        <div class="ghostBox">
            A
        </div>
    </div>

    <div class="controls">
        <button id="trigger">Play</button>
        <button id="pause">Pause</button>
        <button id="reset">Set to start point</button>
        <button id="halfway">Set to midway point</button>
        <button id="end">Set to end point</button>

        <input type="range" id="scrubber" name="scrubber" min="0" max="1" step="0.01">
    </div>
</section>

<script src="../../js/components/waapi-transform-ordering-3.js"></script>
<section id="waapi-transform-ordering-3" class="animate-things-wrapper-b">
    <div id="mains">
        <div id="boxContainerA">
            <div data-translate="">
                <div data-rotate="">
                    <div data-scale="">
                        <div class="box">
                            Translate -> Rotate -> Scale
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div id="boxContainerB">
            <div data-scale="">
                <div data-translate="">
                    <div data-rotate="">
                        <div class="box">
                            Scale -> Translate -> Rotate
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="ghosts">
        <div class="ghostBox">
            A
        </div>
    </div>

    <div class="controls">
        <button id="trigger">Play</button>
        <button id="pause">Pause</button>
        <button id="reset">Set to start point</button>
        <button id="halfway">Set to midway point</button>
        <button id="end">Set to end point</button>

        <input type="range" id="scrubber" name="scrubber"
               min="0" max="1" step="0.01">
    </div>
</section>

<script src="{{ path '/js/components/waapi-transform-ordering-3.js' }}"></script>
/* No context defined. */
  • Content:
    (function () {
      document.addEventListener('DOMContentLoaded', function () {
        console.log("waapi-transform-ordering-3 active");
    
        const button = document.querySelector('#trigger');
        const pause = document.querySelector('#pause');
        const halfway = document.querySelector('#halfway');
        const end = document.querySelector('#end');
        const reset = document.querySelector('#reset');
        const scrubber = document.querySelector('#scrubber');
    
        const boxA = document.querySelector('#boxContainerA');
        const boxB = document.querySelector('#boxContainerB');
    
        const boxTranslate = boxA.querySelector('[data-translate]');
        const boxRotate = boxA.querySelector('[data-rotate]');
        const boxScale = boxA.querySelector('[data-scale]');
    
        const boxTranslateB = boxB.querySelector('[data-translate]');
        const boxRotateB = boxB.querySelector('[data-rotate]');
        const boxScaleB = boxB.querySelector('[data-scale]');
    
        const animTranslateX = [{
          transform: `translateX(-300px)`,
        }, {
          transform: 'translateX(300px)',
        }];
    
        const animTranslateY = [{
          transform: `translateY(-300px)`,
        }, {
          transform: 'translateY(300px)',
        }];
    
        const animRotate = [{
          transform: `rotate(-90deg)`,
        }, {
          transform: 'rotate(90deg)',
        }, {
          transform: 'rotate(-90deg)',
        }];
    
        const animScale = [{
          transform: `scale(0.15)`,
        }, {
          transform: 'scale(1.5)',
        }, {
          transform: 'scale(0.15)',
        }];
    
        const totalDuration = 5000;
    
        const timingA = {
          duration: totalDuration,
          easing: 'cubic-bezier(.42,0,.58,1)',
          iterations: 1,
          fill: 'forwards',
          delay: 0,
          endDelay: 0
        };
    
        const timings = [
          timingA,
        ];
    
        timings.forEach((timing) => {
          timing.duration = totalDuration - timing.delay - timing.endDelay;
        });
    
        let anims = [];
    
        function makeAnim(el, animation, timing) {
          const anim = el.animate(animation, timing);
          anim.pause();
          anims.push(anim);
        }
    
        // const boxAnim = box.animate(animInA, timingA);
        // boxAnim.pause();
    
        makeAnim(boxTranslate, animTranslateX, timingA);
        makeAnim(boxRotate, animRotate, timingA);
        makeAnim(boxScale, animScale, timingA);
    
        makeAnim(boxTranslateB, animTranslateX, timingA);
        makeAnim(boxRotateB, animRotate, timingA);
        makeAnim(boxScaleB, animScale, timingA);
    
        // Controls
    
        button.addEventListener('click', function () {
          anims.forEach((anim) => anim.play());
        });
    
        pause.addEventListener('click', function () {
          anims.forEach((anim) => anim.pause());
        });
    
        halfway.addEventListener('click', function () {
          anims.forEach((anim) => {
            anim.pause();
            anim.currentTime = totalDuration / 2;
          });
        });
    
        end.addEventListener('click', function () {
          anims.forEach((anim) => {
            anim.pause();
            anim.currentTime = totalDuration;
          });
        });
    
        reset.addEventListener('click', function () {
          anims.forEach((anim) => {
            anim.pause();
            anim.currentTime = 0;
          });
        });
    
        scrubber.addEventListener('input', function () {
          anims.forEach((anim) => {
            anim.pause();
            anim.currentTime = scrubber.valueAsNumber * totalDuration;
          })
        })
      });
    })();
    
  • URL: /components/raw/waapi-transform-ordering-3/waapi-transform-ordering-3.js
  • Filesystem Path: components/03-waapi/08-waapi-transform-ordering-3/waapi-transform-ordering-3.js
  • Size: 3.3 KB
  • Content:
    #waapi-transform-ordering-3 {
      text-align: center;
    
      &:after {
        position: absolute;
        top: 0;
        bottom: 0;
        left: calc(50% - 1px);
        width: 2px;
        background-color: gray;
        content: "";
      }
    
      .controls {
        position: fixed;
        bottom: 0;
        left: 0;
        display: flex;
        flex-flow: row nowrap;
        align-items: center;
        justify-content: normal;
    
        > * {
          margin-right: 1rem;
        }
      }
    
      .box {
        border: 2px solid #ff0000;
      }
    
      #boxContainerB * {
        transform-origin: center center;
      }
    
      #ghosts,
      #mains {
        position: absolute;
        top: 0;
        left: 0;
        height: 100vh;
        width: 100vw;
    
        display: flex;
        flex-flow: column nowrap;
        align-items: center;
        justify-content: center;
    
        > * {
          margin: 1rem;
        }
    
        .ghostBox {
          border: 1px solid pink;
          display: flex;
          flex-flow: row nowrap;
          align-items: center;
          justify-content: center;
    
          height: 100px;
          width: 100px;
        }
      }
    }
    
  • URL: /components/raw/waapi-transform-ordering-3/waapi-transform-ordering-3.scss
  • Filesystem Path: components/03-waapi/08-waapi-transform-ordering-3/waapi-transform-ordering-3.scss
  • Size: 986 Bytes
  • Handle: @waapi-transform-ordering-3
  • Preview:
  • Filesystem Path: components/03-waapi/08-waapi-transform-ordering-3/waapi-transform-ordering-3.hbs

No notes defined.