【发布时间】:2020-05-26 19:26:33
【问题描述】:
在我的 index.html 上一切正常。在第一个 .onload 页面上,所有图像都是可拖动的,并且遍布整个页面
问题出在这里:
但是,当我转到页面 ABOUT.html 并返回到 INDEX.html 时,我的脚本看起来不再工作了,我只能看到一个甚至无法拖动的图像没有了。
在这里仔细看看我的项目: https://codepen.io/cat999/project/editor/AEeEdg
** 如何解决问题?有人可以帮我修复我的代码吗? **
var winWidth = window.innerWidth,
winHeight = window.innerHeight,
threeWinHeight = winHeight*3;
$(window).on('resize', function(){
winHeight = window.innerHeight,
twiceWinHeight = winHeight*2;
});
$('.shape').each(function(){
var topPos = Math.floor(Math.random()*1300),
//BE CAREFUL 7000px is less then total body height or CAUSING OVERFLOW
leftPos = Math.floor(Math.random() * winWidth);
$(this).css('top', topPos + 'px');
$(this).css('left', leftPos + 'px');
});
Draggable.create('.shape', {
//type:"rotation",
bounds: '.section-2',
edgeResistance:0.65,
throwProps:true,
});
var number = Math.floor((Math.random() *15) + 2);
var number2 = Math.floor((Math.random() * 0) + -15);
var number3 = Math.floor((Math.random() * 0) + 15);
var number4 = Math.floor((Math.random() * 0) + 6);
$(".shape--circle").css("transform", "rotate(" + number2 + "deg)");
$(".shape--square").css("transform", "rotate(" + number3 + "deg)");
$(".shape--circle-2").css("transform", "rotate(" + number4 + "deg)");
此外,index 和 about 部分使用 barba.js。 这是我的脚本列表:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/TweenMax.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/utils/Draggable.min.js"></script>
<script type="text/javascript" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/ThrowPropsPlugin.min.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://unpkg.com/@barba/core"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js"></script>
<script src="main.js"></script>
【问题讨论】:
标签: javascript html jquery css navigation