jquery支持触摸鼠标滚轮的全屏图片滑块插件

所属分类: 网页特效-图片特效&上传    2023-09-27 08:56:34

 11.2K  0  查看评论 (3)
jquery支持触摸鼠标滚轮的全屏图片滑块插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery支持触摸鼠标滚轮的全屏图片滑块插件(共3个文件)

    • index.html
    • style.css
    • app.js

使用方法

$(document).ready(function () {
  var timeStart = 0;

  function wheely(e) {
    var y = e.originalEvent.deltaY;
    var timeStop = new Date().getTime();
    var timeDiff = timeStop - timeStart;
    if (timeDiff > 200) {
      if (y > 0) {
        nextSlide();
      }
      if (y < 0) {
        prevSlide();
      }
    }
    timeStart = timeStop;
  }

  function prevSlide() {
    if ($(".active").is(":first-child")) {
      if (!$(".slider").hasClass("dragging")) {
        $(".slide:first-child").addClass("bounce");
        setTimeout(function () {
          $(".slide:first-child").removeClass("bounce");
        }, 300);
      }
    } else {
      $(".active")
        .removeClass("active")
        .addClass("queue")
        .prev()
        .removeClass("prev")
        .addClass("active");
    }
  }

  function nextSlide() {
    if ($(".active").is(":last-child")) {
      if (!$(".slider").hasClass("dragging")) {
        $(".slide:last-child").addClass("bounce");
        setTimeout(function () {
          $(".slide:last-child").removeClass("bounce");
        }, 300);
      }
    } else {
      $(".active")
        .removeClass("active")
        .addClass("prev")
        .next()
        .removeClass("queue")
        .addClass("active");
    }
  }

  function hotkeys(e) {
    if (e.keyCode == 38) {
      prevSlide();
    }

    if (e.keyCode == 40) {
      e.preventDefault();
      nextSlide();
    }
  }

  function dragStart(e) {
    e.preventDefault();
    if (e.type == "touchstart") {
      $(document).off("mousedown", dragStart);
      startPoint = e.originalEvent.touches[0].pageY;
    } else {
      startPoint = e.pageY;
    }
    dragDist = 0;
    $(document).on("touchmove mousemove", dragMove);
  }

  function dragMove(e) {
    if (e.type == "touchmove") {
      var movePoint = e.originalEvent.touches[0].pageY;
    } else {
      var movePoint = e.pageY;
    }
    dragDist = ((movePoint - startPoint) / $(".slider").height()) * 100;

    $(".slider").addClass("dragging");

    $(".slide, .bg").css({
      transition: "0ms",
    });

    if (dragDist < 0) {
      $(".active .bg").css({
        opacity: 1 + dragDist / 200,
      });
      $(".active")
        .css({
          transform: "translate3d(0," + dragDist / 2 + "%,0)",
        })
        .next()
        .css({
          transform: "translate3d(0," + (100 + dragDist) + "%,0)",
        });
    }

    if (dragDist > 0) {
      $(".active")
        .css({
          transform: "translate3d(0," + dragDist + "%,0)",
        })
        .prev()
        .css({
          animation: "none",
          transform: "translate3d(0," + (-50 + dragDist / 2) + "%,0)",
        })
        .find(".bg")
        .css({
          opacity: 0.5 + dragDist / 200,
        });
    }
  }

  function dragEnd() {
    $(document).off("touchmove mousemove", dragMove);
    $(".slide, .bg").removeAttr("style");
    if (dragDist > 20) {
      prevSlide();
    }
    if (dragDist < -20) {
      nextSlide();
    }

    setTimeout(function () {
      $(".slider").removeClass("dragging");
    }, 800);
  }

  $(document).on("wheel", wheely);
  $(document).on("keydown", hotkeys);
  $(document).on("touchstart mousedown", dragStart);
  $(document).on("touchend mouseup", dragEnd);
});

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 图片特效&上传

javascript3D幻灯片产品图片展示特效代码

一款动态的产品展示效果,点击鞋盒即可触发开箱动画及查看鞋子图片,还有产品名称和价格的变换。
  图片特效&上传
 8479  0

原生jsCSS3拖动平移放大/缩小图片插件

一款老虎头缩放特效,支持鼠标拖动图片,非常不错的功能。
  图片特效&上传
 61235  0

jquery响应式Coverflow触摸轮换滑块插件

一款支持触屏滑动的3D幻灯片特效,提供了4种轮换模式,很不错!
  图片特效&上传
 4797  0

纯css3鼠标悬停3D翻转动画特效代码

一款悬停图片动画翻转特效,鼠标移出恢复原状,非常的实用漂亮。
  图片特效&上传
 9728  0

评论数(3) 回复有机会获得K币 用户协议

    xiaoshenzhen0
    2023-09-28 13:21:57
    xiaoshenzhen0
    2023-09-28 13:19:08
    0
    2023-09-28 11:27:22
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论