我希望使用Greensock和jQuery库只触发一次scroll事件。我希望对#aboutSection
上的每个滚动始终进行CSS转换,但我希望GreenSock(TweenMax.set
,TweenMax.to
)事件只发生一次
以下是我目前使用的代码:
$(window).scroll({
topOfCallout: $("#aboutSection")
}, function() {
var currentTop = $(window).scrollTop();
if (currentTop >= $(".webDevSection").offset().top) {
$(".aboutSectionSkewBottom").css({
'transform': 'skew(0deg, 0deg)',
'margin-top': '-90px',
'transition': 'transform 1s ease-in, margin-top 1s ease-in'
});
var rounded = $(".roundedImage");
TweenMax.set($(rounded), {
x: 670,
scale: 1,
alpha: 0
});
TweenMax.to($(rounded), 1, {
scale: 1,
alpha: 1
});
} else {
$(".aboutSectionSkewBottom").css({
'transform': 'skew(0deg, 4deg)',
'margin-top': '-50px',
'transition': 'transform 1s ease-in, margin-top 1s ease-in'
});
rounded = false;
}
});