Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将同级元素滑动到已从DOM中删除前一个同级元素的位置_Javascript_Html_Css_Css Transitions_Css Animations - Fatal编程技术网

Javascript 将同级元素滑动到已从DOM中删除前一个同级元素的位置

Javascript 将同级元素滑动到已从DOM中删除前一个同级元素的位置,javascript,html,css,css-transitions,css-animations,Javascript,Html,Css,Css Transitions,Css Animations,我试图模仿IOS上的instagram建议组件。当一个元素从父容器中移除时,它旁边的下一个同级元素将滑动到位。我有以下实现,但向左滑动(动画/过渡:marginLeft是我遇到的问题)下面是一些代码和指向画笔的链接 closeIcon.addEventListener('click', function(event) { var fadeInterval, slideInterval, closeIconParent = event.curr

我试图模仿IOS上的instagram建议组件。当一个元素从父容器中移除时,它旁边的下一个同级元素将滑动到位。我有以下实现,但向左滑动(动画/过渡:marginLeft是我遇到的问题)下面是一些代码和指向画笔的链接

    closeIcon.addEventListener('click', function(event) {
     var fadeInterval,
         slideInterval,
         closeIconParent = event.currentTarget.parentNode,
         cardParent = closeIconParent.parentNode,
         nextElement = closeIconParent.nextSibling.nextElementSibling;

    fadeInterval = setInterval(function() {
      if(!closeIconParent.style.opacity && !nextElement.style.marginLeft) {
         closeIconParent.style.opacity = 1;
       }
      if(closeIconParent.style.opacity < 0) {
        clearInterval(fadeInterval);
      }else {
        closeIconParent.style.opacity -= 0.1;
      }
    }, 100);
     setTimeout(function() {
       cardParent.removeChild(closeIconParent);
       nextElement.classList.add('instagramCard-moveLeft')
     }, 800)
   })
 })
}
closeIcon.addEventListener('click',函数(事件){
var fadeInterval,
slideInterval,
closeIconParent=event.currentTarget.parentNode,
cardParent=closeIconParent.parentNode,
nextElement=closeIconParent.nextSibling.nextElementSibling;
fadeInterval=setInterval(函数(){
如果(!closeIconParent.style.opacity&&!nextElement.style.marginLeft){
closeIconParent.style.opacity=1;
}
if(closeIconParent.style.opacity<0){
清除间隔(fadeInterval);
}否则{
closeIconParent.style.opacity-=0.1;
}
}, 100);
setTimeout(函数(){
cardParent.removeChild(closeIconParent);
nextElement.classList.add('instagramCard-moveLeft')
}, 800)
})
})
}

我没有看到您在moveLeft类中设置margin left属性的位置。它只设置了转换。最近我用左边的卷轴做了类似的事情。您可以尝试将整行向左移动,然后删除从视图中隐藏后单击的元素。我看不到您在moveLeft类中设置margin left属性的位置。它只设置了转换。最近我用左边的卷轴做了类似的事情。您可以尝试将整行向左移动,然后删除从视图中隐藏后单击的元素。