English 中文(简体)
热母固定浮游轮
原标题:Smoother fixed float

我为

我使用了固定的思想,但试图将其限制在管线上。 它不是完美的,而是得到页数短的帮助。

How could I make it smoother (particularly when scrolling slowly)?

Also, when I scroll with my iPhone, it works but only after I finish scrolling and not as I m scrolling. Is this just a limitation of the iPhone s scrolling mechanism or is there a way around that?


The HTML:

<div id="spirit_level"> 
    <div id="shimmery"></div> <!-- just for y gradient -->
    <div id="shimmerx"></div> <!-- just for x gradient -->
    <div id="bumps"></div> <!-- just for another overlay -->

    <div id="tube"> 
        <div id="bubble"></div> 
        <div id="overside"></div> <!-- glass + line markings -->
    </div>
</div>
<div id="spirit_shadow"></div>

The CSS:

精神水平采用固定定位,内部的一切都绝对定位(与精神水平相对)。

The Javascript:

/* START: init spirit_level/bubble */
var bubble_h = 53, tube_h = 242, 
doc_h = parseInt($(document).height()),
viewport_h = parseInt($(window).height()),
scrollDepth = $(document).scrollTop(),
orig_scrollDepth = scrollDepth,
tube_top = viewport_h/2 - tube_h/2,
center = 0;

/*center the tube and bubble:
$( #tube ).css( top , tube_top+ px )
    .addClass( bubble_prep );

placeBubble(1);
/* END: init spirit_level/bubble */

$(window).unbind("scroll").scroll(function () {
    placeBubble(0);
})

www.un.org/Depts/DGACM/index_french.htm

function placeBubble(first_time)
{
    scrollDepth = $(document).scrollTop();
    if(first_time)
    {
        $( #bubble ).css( top , center +  px );                     
    }

    temp = ((center - (scrollDepth - orig_scrollDepth))/viewport_h)*100;

    $( #bubble ).css( top , (temp<-50?-50:(temp>50?50:temp)) + % )
        .animate(
            {top: (center/viewport_h)*100+ % },
            {duration:800,queue:false},
            {
                step: function(now, fx) {
                    //this is never called, don t know why
                    alert(now);
                }
            }, function(){
                /*
                    Should I do the following?
                    orig_scrollDepth = $(document).scrollTop();*/
            });

            /*Without the next line, the bubble slides down from the top of the 
            tube on any length scroll in any direction*/
            orig_scrollDepth = $(document).scrollTop();
     }
}

Edit:

Wow,我刚刚与三星银河S1(标准网络浏览器)进行核对。 测量磁带的z积和绝对定位是灾难性的失败。 为什么如此?

最佳回答

您能否使用<代码>.css? <代码>animate可以是适当的替代物,其环境非常快,从而能够顺利地向临时启动职位 gl光,然后慢慢地向中心 gl光。

$( #bubble ).animate({ top : (temp<-50?-50:(temp>50?50:temp)) + % },{duration:200})
    .animate( [...]
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签