简体   繁体   English

通过超级滚动避免页面宽度

[英]Avoiding page width with superscrollorama

I have setup a few elements with superscrollorama and at the one point when scrolling down one element comes in from the left and another comes from the right and they meet at the middle. 我为superscrollorama设置了一些元素,向下滚动时,一个元素从左侧进入,另一个元素从右侧进入,它们在中间相遇。

The problem is that before scrolling down the user can actually scroll the page way over to the right, to where the element is actually hiding. 问题在于,在向下滚动之前,用户实际上可以将页面向右滚动到元素实际隐藏的位置。

Is there a way to prevent this from happening with superscrollorama? 有没有办法防止这种情况发生在superscrollorama中?

The code I have for the HTML and Javascript is something like this... 我用于HTML和Javascript的代码是这样的...

<div class="row">
    <div class="col-md-6" id="fly-from-left">This content comes from the left</div>
    <div class="col-md-6" id="fly-from-right">This content comes from the right</div>
</div>

<script>
$(document).ready(function() {
    var sscr = $.superscrollorama();
    sscr.addTween('#fly-from-left', TweenMax.from($('#fly-from-left'), 0.5, { css:{right:'10000px'}, ease:Quad.easeInOut }), 0, -350);
    sscr.addTween('#fly-from-right', TweenMax.from($('#fly-from-right'), 0.5, { css:{left:'10000px' }, ease:Quad.easeInOut }), 0, -350);
});
</script>

Assuming you don't have nothing to scroll horizontally in your website, you can use: 假设您没有什么内容可以在网站中水平滚动,则可以使用:

body{
  overflow-x:hidden;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM