Skip to main content
Loading external scripts over HTTPS now.
Source Link
user2570380
user2570380
window.onload = function() {
  TweenLite.to(document.getElementsByClassName("box"), 1, {
    top: 50,
    left: 150,
    onComplete: function() {
      TweenLite.to(this.target, 0.2, {
        opacity: 0,
        onComplete: function() {
          TweenLite.set(this.target, {
            opacity: 1
          });
          this.restart();
        }.bind(this)
      });
    }
  });
};
body {
  margin: 0px;
}
#container {
  position: relative;
}
.wrapper {
  /*position: relative;*/
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.meet {
  position: absolute;
  top: 50px;
  left: 150px;
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
<script src="httpsrc="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/CSSPlugin.min.js"></script>
<script src="httpsrc="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js"></script>
<div id="container">
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="meet"></div>
</div>
window.onload = function() {
  TweenLite.to(document.getElementsByClassName("box"), 1, {
    top: 50,
    left: 150,
    onComplete: function() {
      TweenLite.to(this.target, 0.2, {
        opacity: 0,
        onComplete: function() {
          TweenLite.set(this.target, {
            opacity: 1
          });
          this.restart();
        }.bind(this)
      });
    }
  });
};
body {
  margin: 0px;
}
#container {
  position: relative;
}
.wrapper {
  /*position: relative;*/
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.meet {
  position: absolute;
  top: 50px;
  left: 150px;
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/CSSPlugin.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js"></script>
<div id="container">
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="meet"></div>
</div>
window.onload = function() {
  TweenLite.to(document.getElementsByClassName("box"), 1, {
    top: 50,
    left: 150,
    onComplete: function() {
      TweenLite.to(this.target, 0.2, {
        opacity: 0,
        onComplete: function() {
          TweenLite.set(this.target, {
            opacity: 1
          });
          this.restart();
        }.bind(this)
      });
    }
  });
};
body {
  margin: 0px;
}
#container {
  position: relative;
}
.wrapper {
  /*position: relative;*/
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.meet {
  position: absolute;
  top: 50px;
  left: 150px;
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/CSSPlugin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js"></script>
<div id="container">
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="meet"></div>
</div>
added 1689 characters in body
Source Link
user2570380
user2570380

Here's with CSS only but with multiple keyframe and animation rules.

body {
    margin: 0px;
}

#container {
  position: relative;
}
.wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid black;
}
.meet {
    position: fixed;
    top: 50px;
    left: 150px;
    width: 100px;
    height: 100px;
    border: 1px solid black;
}

.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
.box1 {
  -webkit-animation: boxOne 1s infinite;
}
.box2 {
  -webkit-animation: boxTwo 1s infinite;
}
@-webkit-keyframes boxOne {
  0% {
    left: 0px;
    top: 0px;
    opacity: 1
  }
  80% {
    left: 150px;
    top: 50px;
    opacity: 1
  }
  100% {
    left: 150px;
    top: 50px;
    opacity: 0
  }
}
@-webkit-keyframes boxTwo {
  0% {
    left: 0px;
    top: 0px;
    opacity: 1
  }
  80% {
    left: 150px;
    top: -50px;
    opacity: 1
  }
  100% {
    left: 150px;
    top: -50px;
    opacity: 0
  }
}
<div id="container">
  <div class="wrapper">
      <div class="box box1"></div>
  </div>
  <div class="wrapper">
      <div class="box box2"></div>
  </div>
    <div class="meet">
    </div>
</div>

Here's with CSS only but with multiple keyframe and animation rules.

body {
    margin: 0px;
}

#container {
  position: relative;
}
.wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid black;
}
.meet {
    position: fixed;
    top: 50px;
    left: 150px;
    width: 100px;
    height: 100px;
    border: 1px solid black;
}

.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
.box1 {
  -webkit-animation: boxOne 1s infinite;
}
.box2 {
  -webkit-animation: boxTwo 1s infinite;
}
@-webkit-keyframes boxOne {
  0% {
    left: 0px;
    top: 0px;
    opacity: 1
  }
  80% {
    left: 150px;
    top: 50px;
    opacity: 1
  }
  100% {
    left: 150px;
    top: 50px;
    opacity: 0
  }
}
@-webkit-keyframes boxTwo {
  0% {
    left: 0px;
    top: 0px;
    opacity: 1
  }
  80% {
    left: 150px;
    top: -50px;
    opacity: 1
  }
  100% {
    left: 150px;
    top: -50px;
    opacity: 0
  }
}
<div id="container">
  <div class="wrapper">
      <div class="box box1"></div>
  </div>
  <div class="wrapper">
      <div class="box box2"></div>
  </div>
    <div class="meet">
    </div>
</div>

Source Link
user2570380
user2570380

Lot of divs? With CSS, I'm pretty sure it's not possible without a keyframe rule for each element. With JS, however:

window.onload = function() {
  TweenLite.to(document.getElementsByClassName("box"), 1, {
    top: 50,
    left: 150,
    onComplete: function() {
      TweenLite.to(this.target, 0.2, {
        opacity: 0,
        onComplete: function() {
          TweenLite.set(this.target, {
            opacity: 1
          });
          this.restart();
        }.bind(this)
      });
    }
  });
};
body {
  margin: 0px;
}
#container {
  position: relative;
}
.wrapper {
  /*position: relative;*/
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.meet {
  position: absolute;
  top: 50px;
  left: 150px;
  width: 100px;
  height: 100px;
  border: 1px solid black;
}
.box {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: coral;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/CSSPlugin.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js"></script>
<div id="container">
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="wrapper">
    <div class="box"></div>
  </div>
  <div class="meet"></div>
</div>