滚动位置重置“混蛋” [英] Scroll Position Reset "jerks"

查看:160
本文介绍了滚动位置重置“混蛋”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我正在努力做一些不可能的事情。


我有一个< div>溢出样式设置为滚动的元素。换句话说,我的< div> element允许用户滚动其中的内容。


此< div>中有许多元素。导致< div>参与对服务器的Ajax调用。


为了保持< div>的滚动位置在Ajax请求期间,我将滚动值存储在隐藏字段中,以便当Ajax请求返回到浏览器时,我可以调用一个JavaScript函数来检索此值并重置< div>的滚动位置。
<除了在某些浏览器中,当从Ajax请求返回时重置滚动位置时,该过程非常明显,所以一切都在做它应该做的事情。让我试着更好地解释一下。


< div>的滚动位置当Ajax请求返回时设置为0,然后在所有内容加载后调用JavaScript以将滚动位置重置为它的最后一个值。存在一个分割秒,其中内容在0位置被重绘,并且当滚动被重置为它的前一个位置时,内容(和滚动条)加速。进入正确的位置。


我试图摆脱生涩但我不知道如何解决这个问题。


我想如果我放置了可滚动的内容< div>进入另一个孩子< div>,也许我可以设置可滚动< div>的滚动位置在孩子之前< div>装,但显然我不能这样做。 (我的无法设置滚动位置大于内容可以滚动的最大值,因为内容没有被加载,所以它是0 ...所以你可以看出我为什么遇到这种尝试的问题。)


有没有人对如何解决这个问题有任何指示?


谢谢!


-Frinny

解决方案

我想跟随;)......那个div里有很多内容吗?如果没有很多节点,我会尝试克隆div节点并将其置于有问题的div之上。现在在隐藏或更好的隐形div中执行所有操作,然后删除掩蔽div ...或者您是否有想要在滚动操作中明确显示的滚动动画?


亲切的问候


关于克隆,我没有关注你。在我的情况下,有一个表有40列和512行超链接(加上标题中的任何链接或侧面的行标题)。所以,内容非常大。


我不希望滚动过程动画,它真的不应该显而易见。当用户点击其中一个链接时,它会发布到服务器上,该服务器会更新页面上不同部分的某些内容以及他们点击的详细信息。


我很感兴趣在你的克隆中理念。你能详细说明吗?


谢谢:)


-Frinny


我想知道是否设置发送请求后暂时溢出固定,并在请求完成后将其更改回 auto 会对您有用。

I think I''m trying to do something impossible.

I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it.

There are a number of elements within this <div> that cause the <div> to participate in an Ajax call to the server.

In order to maintain the scroll position of the <div> during the Ajax request I store the scroll value in a hidden field so that when the Ajax request returns to the browser I can call a JavaScript function that retrieves this value and resets the scroll position of the <div>.

Everything''s doing what it should except that in some browsers the process is very apparent when the scroll position is reset upon returning from the Ajax request. Let me try to explain this better.

The scroll position of the <div> is set to 0 when the Ajax request returns and then after everything has loaded the JavaScript is called to reset the scroll position to it''s last value. There is a Split second where the content is redrawn at the 0 position and when the scroll is reset to it''s previous position the content (and scroll bar) "jerks" into the right position.

I am trying to get rid of the "jerkyness" but I have No idea how to solve this problem.

I thought that if I placed the content of the scrollable <div> into another child <div>, that maybe I could set the scroll position of the scrollable <div> before the child <div> loaded but apparently I can''t do this. (I cannot set the scroll position larger than the maximum that the content can be scrolled and since the content isn''t loaded it''s 0 ...so you can see why I''m having problems with this attempt.)

Does anyone have any pointers on how to solve this problem?

Thanks!

-Frinny

解决方案

i''m trying to follow ;) ... is there much content in that div? in case there are not a lot of nodes i would try to just clone the div node and place it ''over'' the div in question. now do everything in the ''hidden'' or better invisible div and then remove the ''masking'' div ... or do you have a scroll-animation that you want to have explicitly shown on the scroll-operation?

kind regards


I''m not following you with regards to the "cloning" thing.

In my case there is a table that has 40 columns and 512 rows of hyperlinks (plus any links in the headers or the "row headers" down the side). So, the content is quite large.

I do not want the scrolling process to be animated, it should not be apparent at all really. When the user clicks one of the links it posts to the server which updates some content in a different section on the page with the details of what they clicked on.

I''m interested in your "cloning" idea. Could you please elaborate?

Thanks :)

-Frinny


I was wondering if setting the overflow to fixed temporarily just after sending the request, and changing it back to auto when request completed would do something useful for you.


这篇关于滚动位置重置“混蛋”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆