Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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 MD引导转盘项目的视差效应 我在MD引导转盘的所有图像上使用视差效果时遇到一些问题。 当前状态:效果本身可以工作,但是如果我在滑块中更改图片,由于视差代码,其样式将重置。仅为当前图像计算偏移量。(如果在更改图像后向下滚动,则会在图像中产生跳跃效果) 我的目标是:为每个旋转木马项目设置偏移(顶部,变换:平移)。我这样试过:_Javascript_Jquery_Css_Parallax_Mdbootstrap - Fatal编程技术网

Javascript MD引导转盘项目的视差效应 我在MD引导转盘的所有图像上使用视差效果时遇到一些问题。 当前状态:效果本身可以工作,但是如果我在滑块中更改图片,由于视差代码,其样式将重置。仅为当前图像计算偏移量。(如果在更改图像后向下滚动,则会在图像中产生跳跃效果) 我的目标是:为每个旋转木马项目设置偏移(顶部,变换:平移)。我这样试过:

Javascript MD引导转盘项目的视差效应 我在MD引导转盘的所有图像上使用视差效果时遇到一些问题。 当前状态:效果本身可以工作,但是如果我在滑块中更改图片,由于视差代码,其样式将重置。仅为当前图像计算偏移量。(如果在更改图像后向下滚动,则会在图像中产生跳跃效果) 我的目标是:为每个旋转木马项目设置偏移(顶部,变换:平移)。我这样试过:,javascript,jquery,css,parallax,mdbootstrap,Javascript,Jquery,Css,Parallax,Mdbootstrap,设置样式代码: // carouse-control-next is the button to change slides $(".carousel-control-next").click(function () { for (let i = 1; i <= $(".img-parallax-gallery").length; i++) { // pictures of the gallery let na

设置样式代码:

  // carouse-control-next is the button to change slides
  $(".carousel-control-next").click(function () {
    for (let i = 1; i <= $(".img-parallax-gallery").length; i++) {
      // pictures of the gallery
      let name = "img-parallax-gallery-" + i;
      $("#" + name).css({
        top: imageSize + "%",
        transform: "translate(-50%, -" + imageSize + "%)",
      });
    }
  });
//旋转控制下一步是更改幻灯片的按钮
$(“.carousel控件下一步”)。单击(函数(){
for(设i=1;i imgY&&winY
jQuery(document).ready(function ($) {
  $(".img-parallax").each(function () {
    var img = $(this);
    var imgParent = $(this).parent();

    function parallaxImg() {
      var speed = img.data("speed");
      var imgY = imgParent.offset().top;
      var winY = $(this).scrollTop();
      var winH = $(this).height();
      var parentH = imgParent.innerHeight();

      // The next pixel to show on screen
      var winBottom = winY + winH;

      // If block is shown on screen
      if (winBottom > imgY && winY < imgY + parentH) {
        // Number of pixels shown after block appear
        var imgBottom = (winBottom - imgY) * speed;
        // Max number of pixels until block disappear
        var imgTop = winH + parentH;
        // Porcentage between start showing until disappearing
        var imgPercent = (imgBottom / imgTop) * 100 + (50 - speed * 50);
      }
      img.css({
        top: imgPercent + "%",
        transform: "translate(-50%, -" + imgPercent + "%)",
      });
    }
    $(document).on({
      scroll: function () {
        parallaxImg();
      },
      ready: function () {
        parallaxImg();
      },
    });
  });
});