侧边栏下拉时箭头的旋转动画(treeView控件)


//点击菜单时箭头旋转
let treeView = document.getElementsByClassName("treeview");//let解决闭包问题
let last=document;
  for (let i = 0; i <treeView.length ; i++) {
    treeView[i].addEventListener("click",function(){
    let that = treeView[i];
    if (that.classList.contains("menu-open")){
      last.getElementsByTagName("i")[1].style.transform="rotateZ(180deg)";
      that.getElementsByTagName("i")[1].style.transform="rotateZ(0deg)";
      that.getElementsByTagName("i")[1].style.transition="0.5s";
   }else{
      last.getElementsByTagName("i")[1].style.transform="rotateZ(0deg)";
     that.getElementsByTagName("i")[1].style.transform="rotateZ(180deg)";
     that.getElementsByTagName("i")[1].style.transition="0.5s";
  }

 //把上次点击事件的元素保存
  last = that;
})
}

<!--网页源代码-->

侧边栏下拉时箭头的旋转动画(treeView控件)

 

上一篇:c#-使用TreeView上的StateImageList防止颜色渗色


下一篇:C# TreeView 建立、遍历树(递归)