I want to make a div (button) scroll when I reach a certain scrolling point.Also i want to add classes to the other elements on the page.Somehow it isnt working.Here is the code Im using for the scroll,but I dont quite understand it.Please help me
$(window).load(function () {
var nav = get_nav();
if (!(nav.is_msie && nav.ver <= 6)) {
var tmp1 = $('#tag_container').css('position');
var cur_w_offset = start_offset = $('#butoni').offset().top;
var bp = $('#right_content');
var pt = $('#butoni');
cur_w_offset = $(window).scrollTop();
if (cur_w_offset >= start_offset) {
bp.addClass('flyingbuy');
} else {
pt.css('top', 'auto');
}
if (window.content_center != true || window.c != false) {
window.buydeal_forpresent = false;
}
$(window).scroll(function () {
var tmp = $('#tag_container').css('position');
ur_w_offset = $(window).scrollTop();
if (cur_w_offset >= start_offset) {
bp.addClass('flyingbuy');
$('#tag_container').css('height', 'auto');
$('#tag_container_bialo').slideDown('slow');
} else {
bp.removeClass('flyingbuy');
$('#tag_container').css(({
position: "fixed",
height: "101px"
}));
$('#tag_container_bialo').slideUp('slow');
}
if (!window.buydeal_forpresent) {
var nvp_panel = $('#right_content');
var nvp_pricetag = $('#butoni');
var bialo_height = $('#tag_container_bialo').height() + 20;
var offset_top = nvp_pricetag.offset().top - nvp_panel.offset().top + 16;
if (tmp == 'fixed') {
$('#gift').css('position', 'fixed');
var left = $('#butoni').offset().left + 223 - 18;
$('#gift').css('top', 16 + bialo_height + 'px');
$('#gift').css('left', left + 'px');
} else {
$('#gift').css('position', 'absolute');
$('#gift').css('top', offset_top);
$('#gift').css('left', '205px');
$('#gift').animate({
top: offset_top + bialo_height
}, 400);
}
}
});
}
});
I have a problem now.I've been working here : JsFiddle
I don't want the text div to scroll that way.When the pages reaches at the button's level ,I want the txt to show,sliding down and moving along with the button.But,the text needs to be BEFORE the button.I don't know why it grows when sliding down.The sliding up part is ok.
Ok,i found out the growing part.I didnt specify the height.
I really dont know how can I make the txt appear before the button and slide together.Like this:
TEXT
BUTTON
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…