Javascript 固定弹出窗口,使其平稳上升

Javascript 固定弹出窗口,使其平稳上升,javascript,jquery,html,css,popup,Javascript,Jquery,Html,Css,Popup,我创建了一个弹出对话框,当用户滚动页面时,它会从左下角弹出。 你可以在这里看到它- 我的问题是,它没有顺利地提出第一次,然后它是好的。任何人,请提出任何想法来解决它。需要使电梯平稳上升 我的代码 <div id="scrolltriggered" style="width: 310px; left: 10px; bottom: 10px;"> <div id="inscroll"> <a href="#close" id="closebox">x<

我创建了一个弹出对话框,当用户滚动页面时,它会从左下角弹出。 你可以在这里看到它-

我的问题是,它没有顺利地提出第一次,然后它是好的。任何人,请提出任何想法来解决它。需要使电梯平稳上升

我的代码

<div id="scrolltriggered" style="width: 310px; left: 10px; bottom: 10px;">
<div id="inscroll">
    <a href="#close" id="closebox">x</a><a href="http://www.google.com" target="_blank"><img src="images/buyersguide.png" alt="Free Resources" height="235" width="310">
     </a>
</div>
</div>


<script type="text/javascript"> 
var stb = {
hascolsed: false,
cookieLife: 7,
triggerHeight: 30,
stbElement: ""
}; 
</script>

var stb={
哈斯科尔斯:错,
库克生活:7,
身高:30,,
标题:“
}; 
Javascript代码-

if (typeof stb === "undefined")
var stb = {};
jQuery(document).ready(function () {
jQuery("#closebox").click(function () {
    jQuery('#scrolltriggered').stop(true, true).animate({ 'bottom':'-210px' }, 700, function () {
        jQuery('#scrolltriggered').hide();
        stb.hascolsed = true;
        jQuery.cookie('nopopup', 'true', { expires: stb.cookieLife, path: '/' });
    });
    return false;
});

stb.windowheight = jQuery(window).height();
stb.totalheight = jQuery(document).height();
stb.boxOffset = '';
if (stb.stbElement != '') {
    stb.boxOffset = jQuery(stb.stbElement).offset().top;
}
jQuery(window).resize(function () {
    stb.windowheight = jQuery(window).height();
    stb.totalheight = jQuery(document).height();
});

jQuery(window).scroll(function () {
    stb.y = jQuery(window).scrollTop();
    stb.boxHeight = jQuery('#scrolltriggered').outerHeight();
    stb.scrolled = parseInt((stb.y + stb.windowheight) / stb.totalheight * 100);


    if (stb.showBox(stb.scrolled, stb.triggerHeight, stb.y) && jQuery('#scrolltriggered').is(":hidden") && stb.hascolsed != true) {
        jQuery('#scrolltriggered').show();
        jQuery('#scrolltriggered').stop(true, true).animate({ 'bottom':'10px' }, 700, function () {
        });
    }
    else if (!stb.showBox(stb.scrolled, stb.triggerHeight, stb.y) && jQuery('#scrolltriggered').is(":visible") && jQuery('#scrolltriggered:animated').length < 1) {
        jQuery('#scrolltriggered').stop(true, true).animate({ 'bottom':-stb.boxHeight }, 700, function () {
            jQuery('#scrolltriggered').hide();
        });
    }
});

jQuery('#stbContactForm').submit(function (e) {
    e.preventDefault();
    stb.data = jQuery('#stbContactForm').serialize();

    jQuery.ajax({
        url:stbAjax.ajaxurl,
        data:{
            action:'stb_form_process',
            stbNonce:stbAjax.stbNonce,
            data:stb.data
        },
        dataType:'html',
        type:'post'

    }).done(function (data) {
            jQuery('#stbMsgArea').html(data).show('fast');
        });

    return false;
});
});

(function(stb_helpers) {
stb_helpers.showBox = function(scrolled, triggerHeight, y) {
    if (stb.isMobile()) return false;
    if (stb.stbElement == '') {
        if (scrolled >= triggerHeight) {
            return true;
        }
    }
    else {
        if (stb.boxOffset < (stb.windowheight + y)) {
            return true;
        }
    }
    return false;
};
stb_helpers.isMobile = function(){
    if (navigator.userAgent.match(/Android/i)
        || navigator.userAgent.match(/webOS/i)
        || navigator.userAgent.match(/iPhone/i)
        || navigator.userAgent.match(/iPod/i)
        || navigator.userAgent.match(/BlackBerry/i)
        ) {
        return true;
    }
    else return false;
}
})(stb);
if(机顶盒类型==“未定义”)
var stb={};
jQuery(文档).ready(函数(){
jQuery(“#closebox”)。单击(函数(){
jQuery('#scrolltriggered').stop(true,true).animate({'bottom':'-210px'},700,function(){
jQuery('#scrolltriggered').hide();
stb.hascolsed=true;
cookie('nopopp','true',{expires:stb.cookieLife,path:'/'});
});
返回false;
});
stb.windowheight=jQuery(window.height();
stb.totalheight=jQuery(document).height();
机顶盒偏移量=“”;
如果(stb.stbElement!=''){
stb.boxOffset=jQuery(stb.stbElement).offset().top;
}
jQuery(窗口).调整大小(函数(){
stb.windowheight=jQuery(window.height();
stb.totalheight=jQuery(document).height();
});
jQuery(窗口).滚动(函数(){
stb.y=jQuery(window.scrollTop();
stb.boxHeight=jQuery('#scrolltriggered').outerHeight();
stb.scrolled=parseInt((stb.y+stb.windowheight)/stb.totalheight*100);
if(stb.showBox(stb.scrolled、stb.triggerHeight、stb.y)和&jQuery(“#scrolltrigger”).is(“:hidden”)&&stb.hascolsed!=true){
jQuery('#scrolltriggered').show();
jQuery('#scrolltriggered').stop(true,true).动画({'bottom':'10px'},700,函数(){
});
}
如果(!stb.showBox(stb.scrolled,stb.triggerHeight,stb.y)和&jQuery('scrolltriggered')是(“:可见的”)&&jQuery('scrolltriggered:animated')。长度<1){
jQuery('#scrolltriggered').stop(true,true).animate({'bottom':-stb.boxHeight},700,函数(){
jQuery('#scrolltriggered').hide();
});
}
});
jQuery('#stbContactForm').submit(函数(e){
e、 预防默认值();
stb.data=jQuery('#stbContactForm').serialize();
jQuery.ajax({
url:stbAjax.ajaxurl,
数据:{
措施:'stb表格处理',
stbnoce:stbAjax.stbnoce,
数据:机顶盒数据
},
数据类型:'html',
类型:'post'
}).完成(功能(数据){
jQuery('#stbMsgArea').html(data.show('fast');
});
返回false;
});
});
(功能(机顶盒助手){
stb_helpers.showBox=函数(滚动、触发高度、y){
if(stb.isMobile())返回false;
如果(stb.stbElement=''){
如果(滚动>=触发高度){
返回true;
}
}
否则{
如果(机顶盒偏移量<(机顶盒窗口高度+y)){
返回true;
}
}
返回false;
};
stb_helpers.isMobile=函数(){
if(navigator.userAgent.match(/Android/i)
||navigator.userAgent.match(/webOS/i)
||navigator.userAgent.match(/iPhone/i)
||navigator.userAgent.match(/iPod/i)
||navigator.userAgent.match(/BlackBerry/i)
) {
返回true;
}
否则返回false;
}
})(机顶盒);

我认为您需要更改css,请将以下内容复制粘贴到您的aspx中

<div style="width: 310px; left: 10px; bottom: -225px; display: none;" id="scrolltriggered">


希望对您有所帮助

我认为您需要更改css,请在您的aspx中复制粘贴以下内容

<div style="width: 310px; left: 10px; bottom: -225px; display: none;" id="scrolltriggered">


希望对您有所帮助

您只需将以下行添加到文档中即可作为第一行

$("#scrolltriggered").css({bottom: -235});
这将确保弹出窗口滚动到底部235px。如果需要滚动,可以使用jquery选择器可变地添加元素高度


查看小提琴

您只需将以下行添加到文档中即可作为第一行

$("#scrolltriggered").css({bottom: -235});
这将确保弹出窗口滚动到底部235px。如果需要滚动,可以使用jquery选择器可变地添加元素高度

看到小提琴了吗