无限卷轴dosn';当出现新元素时,不能使用jQuery或JavaScript效果

无限卷轴dosn';当出现新元素时,不能使用jQuery或JavaScript效果,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有这样一个代码,使我的砖石元素产生这种视差效果 我已经将无限滚动JS添加到我的页面中,但是当新元素出现时,它们不会与原始元素转换。我认为这与单击时的文档准备功能有关,但我不知道如何实现它。这是密码 这是针对视差元素的: $.fn.moveIt = function(){ var $window = $(window); var instances = []; $(this).each(function(){ instances.push(new moveItItem($

我有这样一个代码,使我的砖石元素产生这种视差效果

我已经将无限滚动JS添加到我的页面中,但是当新元素出现时,它们不会与原始元素转换。我认为这与单击时的文档准备功能有关,但我不知道如何实现它。这是密码

这是针对视差
元素的:

 $.fn.moveIt = function(){
  var $window = $(window);
  var instances = [];

  $(this).each(function(){
    instances.push(new moveItItem($(this)));
  });

  window.onscroll = function(){
    var scrollTop = $window.scrollTop();
    instances.forEach(function(inst){
      inst.update(scrollTop);
    });
  }
}
var moveItItem = function(el){
  this.el = $(el);
  this.speed = parseInt(this.el.attr('data-scroll-speed'));
};

moveItItem.prototype.update = function(scrollTop){
  this.el.css('transform', 'translateY(' + -(scrollTop / this.speed) + 'px)');
};

// Initialization
$(function(){
  $('[data-scroll-speed]').moveIt();
  });
</script>

<script type="text/javascript">
  $(".card").css({ translate: [60,30] }); 






and this is for the infinite scroll 

<script type="text/javascript">
$('.grid').infiniteScroll({
  // options
  path: '.next',
  append: '.grid-item',
  history: false,
});
</script>
$.fn.moveIt=function(){
变量$window=$(window);
var实例=[];
$(this).each(function(){
push(newmoveItem($(this));
});
window.onscroll=函数(){
var scrollTop=$window.scrollTop();
实例.forEach(函数(inst){
安装更新(滚动顶部);
});
}
}
var moveItItem=函数(el){
this.el=$(el);
this.speed=parseInt(this.el.attr('data-scroll-speed');
};
MoveItem.prototype.update=函数(scrollTop){
this.el.css('transform','translateY(+-(scrollpop/this.speed)+'px');
};
//初始化
$(函数(){
$(“[数据滚动速度]”).moveIt();
});
$(“.card”).css({translate:[60,30]});
这是给无限卷轴的
$('.grid').infiniteScroll({
//选择权
路径:'.next',
附加:'.grid项',
历史:错,
});
此外,当新内容加载时,它们不会产生砖石效应。

你可以参考这一点-在谷歌搜索中找到

希望这会有所帮助

HTML:

JQuery:

   $.fn.moveIt = function(){
  var $window = $(window);
  var instances = [];

  $(this).each(function(){
    instances.push(new moveItItem($(this)));
  });

  window.onscroll = function(){
    var scrollTop = $window.scrollTop();
    instances.forEach(function(inst){
      inst.update(scrollTop);
    });
  }
}

var moveItItem = function(el){
  this.el = $(el);
  this.speed = parseInt(this.el.attr('data-scroll-speed'));
};

moveItItem.prototype.update = function(scrollTop){
  this.el.css('transform', 'translateY(' + -(scrollTop / this.speed) + 'px)');
};

// Initialization
$(function(){
  $('[data-scroll-speed]').moveIt();
});

当然……网上有很多关于这方面的教程。Stackoverflow不是“如何”教程服务Stack Overflow不是解决此类问题的最佳场所。如果你试图编写这样的网站代码,请发布你的代码,我们可以帮助你解决问题或优化它。谢谢大家,尽管这个网站并不像你所说的那样是如何编写的。我认为最好是提供这些教程的链接,而不是否决这篇文章。相信我,我到处都在搜索,这就是我来这里的原因。谢谢你的评论,但就我而言,我希望在浏览博客帖子时,整个身体都像一个懒散的卷轴一样。再次感谢您的评论,为页面上的每个元素添加jquery代码。那会有帮助的。我能给你我的网站链接吗
    @import bourbon

body
  font-family: arial, sans-serif

.content
  height: 5000px

.wrapper
  +display(flex)
  +justify-content(center)
  +align-items(center)
  +size(100% 100vh)
  +position(fixed, 0px null null 0px)

.box
  +flex(none)
  +size(100px)
  line-height: 100px
  text-align: center
  font-size: 25px
  color: #fff
  background: #ff8330

  &:nth-of-type(2)
    background: #E01B5D
  &:nth-of-type(3)
    background: #30FFFF
  &:nth-of-type(4)
    background: #B3FF30
  &:nth-of-type(5)
    background: #308AFF
  &:nth-of-type(6)
    background: #1BE059
   $.fn.moveIt = function(){
  var $window = $(window);
  var instances = [];

  $(this).each(function(){
    instances.push(new moveItItem($(this)));
  });

  window.onscroll = function(){
    var scrollTop = $window.scrollTop();
    instances.forEach(function(inst){
      inst.update(scrollTop);
    });
  }
}

var moveItItem = function(el){
  this.el = $(el);
  this.speed = parseInt(this.el.attr('data-scroll-speed'));
};

moveItItem.prototype.update = function(scrollTop){
  this.el.css('transform', 'translateY(' + -(scrollTop / this.speed) + 'px)');
};

// Initialization
$(function(){
  $('[data-scroll-speed]').moveIt();
});