-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Colleen
committed
Sep 29, 2015
1 parent
4cc9103
commit ed7dce9
Showing
2 changed files
with
16 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
var pointsArray = document.getElementsByClassName('point'); | ||
|
||
var animatePoints = function(points) { | ||
var revealPoint = function(index) { | ||
points[index].style.opacity = 1; | ||
points[index].style.transform = "scaleX(1) translateY(0)"; | ||
points[index].style.msTransform = "scaleX(1) translateY(0)"; | ||
points[index].style.WebkitTransform = "scaleX(1) translateY(0)"; | ||
var animatePoints = function() { | ||
var revealPoint = function() { | ||
$(this).css({ | ||
opacity: 1, | ||
transform: 'scaleX(1) translateY(0)' | ||
}); | ||
}; | ||
|
||
for (var i = 0; i < points.length; i++) { | ||
revealPoint(i); | ||
} | ||
$.each($('.point'), revealPoint); | ||
}; | ||
|
||
window.onload = function() { | ||
if (window.innerHeight > 950) { | ||
animatePoints(pointsArray); | ||
$(window).load(function() { | ||
if ($(window).height() > 950) { | ||
animatePoints(); | ||
} | ||
|
||
var sellingPoints = document.getElementsByClassName('selling-points')[0]; | ||
var scrollDistance = sellingPoints.getBoundingClientRect().top - window.innerHeight + 200; | ||
var scrollDistance = $('.selling-points').offset().top - $(window).height() + 200; | ||
|
||
window.addEventListener("scroll", function(event) { | ||
if (document.body.scrollTop >= scrollDistance) { | ||
animatePoints(pointsArray); | ||
$(window).scroll(function(event) { | ||
if ($(window).scrollTop() >= scrollDistance) { | ||
animatePoints(); | ||
} | ||
}); | ||
} | ||
}); |