Created
January 19, 2018 06:38
-
-
Save PopYg/2ac73a21053c4f3d972d214ce07495a9 to your computer and use it in GitHub Desktop.
스크롤에 따른 오브젝트 상하 모션 진행중
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var secTopSet = [ | |
[".js-scr-sec", 100, .5, 100], | |
[".js-scr-sec2", 100, .5, 100] | |
]; | |
var scrInnerStep = []; | |
function scrollEvent() { | |
scrollSet(); | |
scrollMotion(0); | |
$window.scroll(function () { | |
var scrTop = $(this).scrollTop(); | |
scrollMotion(scrTop); | |
}); | |
} | |
scrollEvent(); | |
function scrollSet() { | |
$.each(secTopSet, function (i, v) { | |
$(v[0]).each(function () { | |
var _this = $(this); | |
var secTop = _this.offset().top - v[1]; | |
var secInner = secTop - (window.innerHeight / 2); | |
scrInnerStep.push(secInner); | |
TweenMax.set($(secTopSet[i][0]).find(".js-scr-motion"), {y: v[3]}); | |
}); | |
}); | |
} | |
function scrollMotion(_scrTop) { | |
$.each(scrInnerStep, function (i, v) { | |
if (_scrTop >= v) { | |
if ($(secTopSet[i][0])[0].motion === undefined) { | |
$(secTopSet[i][0]).find(".js-scr-motion").each(function (j) { | |
TweenMax.to($(this), secTopSet[i][2], {y: 0, opacity: 1, delay: .2 * j, ease: es_step}); | |
}); | |
$(secTopSet[i][0])[0].motion = true; | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment