FadeIn effect, when scroll to the object, but if the object is positioned, errors will occur.

var eles = Array.prototype.slice.call(document.querySelectorAll(".animated"));
document.addEventListener("scroll", animatedFadeInUp);
animatedFadeInUp();

function animatedFadeInUp() {
  eles = eles.filter(function(ele) {
    var rect = getRect(ele);
    if (rect.isVisible) {
      ele.classList.add("slideUp");
      return false;
    }
    return true;
  });
  if (eles.length <= 0) document.removeEventListener("scroll", animatedFadeInUp);
}

function getRect(ele) {
  var inHeight = window.innerHeight;
  var rect = ele.getBoundingClientRect();
  rect.isVisible = rect.top - inHeight < 0;
  // rect.isBottom = rect.bottom - inHeight <= 0;
  return rect;
}

if the object does not have a location (position), it will not be affected
, but if it has a location, it will move to a very strange angle first, and then it will change back to its proper position

.
@keyframes slideUp {
  from {
    opacity: 0;
    -webkit-transform: translate3d(0, 20%, 0);
    transform: translate3d(0, 20%, 0);
  }

  to {
    opacity: 1;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

because my actions have transform,
when I locate, I also use transform
like:

position: absolute;
left:15px;
top:50%;
transform: translate(0,-50%);
-webkit-transform: translate(0,-50%);

how to do this: even if you have a location, you can use this action?! And get to the right place?


is really caused by the same transform. During the animation, it will go back to 20% of the place first.

in fact, if your 20% corresponds to now, it is actually-50 + 20 =-30%, and the corresponding end needs to be changed to (0,-50%, 0)

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4fa57-4503a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4fa57-4503a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?