Skip to content

Commit 667b7db

Browse files
authored
Merge pull request #130 from alangordon/issue-99
Comment Alan JS Scripting
2 parents d557e2f + d82016d commit 667b7db

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/alan.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,36 @@
66
<title>Alan</title>
77
<script src="../js/jquery.js" type="text/javascript"></script>
88
<script type="text/javascript">
9+
// setup the hex colours to be used in five different scroll areas
910
var
1011
one = "#10e88a",
1112
two = "#7f3995",
1213
three = "#0d78e7",
1314
four = "#f88f18",
1415
five = "#bb6774";
1516

17+
// this function will fire on user scrolling or touching and dragging (for mobile)
1618
$(window).on("scroll touchmove", function () {
19+
20+
// these statements give the body a new CSS data-color if
21+
// the scrollbar is greater than the elements position on page
22+
// we target each <article> using it's id - #one for example
1723
if ($(document).scrollTop() >= $("#one").position().top) {
1824
$('body').css('background', $("#one").attr("data-color"));
19-
2025
};
2126
if ($(document).scrollTop() > $("#two").position().top) {
2227
$('body').css('background', $("#two").attr("data-color"))
2328
};
2429
if ($(document).scrollTop() > $("#three").position().top) {
25-
2630
$('body').css('background', $("#three").attr("data-color"))
2731
};
2832
if ($(document).scrollTop() > $("#four").position().top) {
29-
3033
$('body').css('background', $("#four").attr("data-color"))
3134
};
3235
if ($(document).scrollTop() >= $("#five").position().top) {
3336
$('body').css('background', $("#five").attr("data-color"))
3437
};
3538
});
36-
jackHarnerSig("light")
3739
</script>
3840
<style>
3941
body {

0 commit comments

Comments
 (0)