• 淡入淡出轮播图


    用原生js写淡入淡出轮播图

    1、轮播图下边的按钮

    for(var i =0;i<aBtn.length;i++){
    aBtn[i].index = i;
    aBtn[i].onmouseover = function(){
    for(var j =0;j<aBtn.length;j++){
    aBtn[j].className = "";
    }
    this.className = "active";
    next = this.index;
    toImg()
    }
    }

    2、轮播图右边的按钮
    aDir[0].onclick = function(){
    if(next == 0){
    next = aLi.length-1;
    }else{
    next --;
    }
    toImg()
    }

    3、轮播图右边的按钮
    aDir[1].onclick = function(){
    if(next == aLi.length-1){
    next = 0;
    }else{
    next ++;
    }
    toImg()
    }

    4、当鼠标移动到轮播图上的时候,运动停止,清除定时器
    oBanner.onmouseover = function(){
    clearInterval(timer);
    }

    5、当鼠标移出轮播图的时候,运动继续
    oBanner.onmouseout = function(){
    autoPlay()
    }
    autoPlay()

    6、定义定时器,开始进行轮播
    function autoPlay(){
    timer = setInterval(function(){
    if(next == aLi.length-1){
    next = 0;
    }else{
    next ++;
    }
    toImg()
    },3000)
    }

    7、定义定时器,li通过透明度叠加来进行轮播转换
    function toImg(){
    move(aLi[iNow],{opacity:0});
    move(aLi[next],{opacity:100});
    iNow = next;
    for(var i =0;i<aBtn.length;i++){
    aBtn[i].className = ""
    }
    aBtn[next].className = "active"
    }

  • 相关阅读:
    水壶-[Kruskal重构树] [解题报告]
    线性求逆元推导
    边界线与两端对齐
    左边竖条的实现方法
    $.ajax()知识
    area热点区域
    AJAX与XMLHttpRequest
    js运行机制
    优先级
    各种图形
  • 原文地址:https://www.cnblogs.com/luxinyi/p/9533471.html
Copyright © 2020-2023  润新知