-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdivfloat.js
More file actions
22 lines (21 loc) · 873 Bytes
/
divfloat.js
File metadata and controls
22 lines (21 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$('document').ready(function(){
$(window).scroll(function(){
var left_offset = $("#left").offset();
var right_offset = $("#right").offset();
if ($(window).scrollTop() + $(window).height() > $("." + ($("#left").attr("class"))).offset().top + 10) {
if ($("." + ($("#left").attr("class"))).offset().left < 0) {
$("#left").animate({"left": 0},2000);
$("." + ($("#left").attr("class"))).removeAttr("id");
}
else if ($("." + ($("#left").attr("class"))).offset().left > 0) {
$("#left").animate({"left": 0},2000);
$("." + ($("#left").attr("class"))).removeAttr("id");
}
}
});
// A trigger function need for every floating div
var i;
for (i=0; i<8; i++) {
$(window).trigger( "scroll" );
}
});