bde-liste/static/js/anim.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-01-07 16:46:33 +00:00
var $animation_elements = $("#prank-desc, #chasse-desc, #notice-espion");
2022-12-15 16:14:41 +00:00
var $window = $(window)
function check_if_in_view() {
var window_height = $window.height();
var window_top_position = $window.scrollTop();
var window_bottom_position = (window_top_position + window_height);
$.each($animation_elements, function() {
var $element = $(this);
var element_height = $element.outerHeight();
var element_top_position = $element.offset().top;
var element_bottom_position = (element_top_position + element_height);
//check to see if this current container is within viewport
if ((element_bottom_position >= window_top_position) &&
2022-12-20 21:52:02 +00:00
(element_top_position <= window_bottom_position) && $element.is(':visible')) {
2022-12-15 16:14:41 +00:00
if(!$element.hasClass('animated')) {
$element.addClass('animated');
2022-12-20 23:12:50 +00:00
var a = new TypeIt('#' + $element.attr('id'), {
2023-01-07 16:46:33 +00:00
speed: 50,
2022-12-20 23:12:50 +00:00
lifeLike: true,
2022-12-15 16:14:41 +00:00
})
.go();
2022-12-20 23:12:50 +00:00
$element.click(function () {
a.options({speed: 20, lifeLike: false});
});
2022-12-15 16:14:41 +00:00
}
}
});
}
2022-12-21 21:20:48 +00:00
$(window).on("scroll resize", check_if_in_view);
$(window).trigger("scroll");
$("#prank-button").hover(function () { $('.hover-circle').fadeIn(100) }, function(){ $('.hover-circle').fadeOut(100) });
2022-12-12 16:44:58 +00:00
$(window).on("load", function() {
2022-12-15 13:30:34 +00:00
/*let type = new TypeIt("#typed-data", {
2022-12-12 16:44:58 +00:00
speed: 10,
startDelay: 0,
cursor: true
})
.go();
2022-12-15 13:30:34 +00:00
$(document).on("click", function() {
type.options({speed: 1});
});*/
2022-12-21 21:20:48 +00:00
2022-12-15 16:14:41 +00:00
});