What happens with jQuery Masonry, when I click back in the browser, it lifts the user back?

Why can't he hold the position in which the user is stopped? Is this normal for freemasonry? When the user clicks on the button, the browser goes to where the user left off, but strangely, Freemasonry makes him SHOOT back up!

By the way, the update works fine. It moves the scroll to where the user left off. But the back does not work.

Edit: when I click back, this is at the top. But then I scroll down a little bit (2 pixels). And then the browser will return to the left position.

Ures.

Edit: if I disable this line, it will work:

$('#grid').masonry({ columnWidth:250, itemSelector:".awallpost", animate:false, resizeable:false });
+3
source share
3 answers

I think I have a workaround for you, but you need to try it out. It works when I review the code and do it manually, and I think it will work. I will explain below.

Before the line of code where you call the plugin masonry()...

$('#grid').masonry({ columnWidth:250, itemSelector:".awallpost", animate:false, resizeable:false });

... set the height of the grid to its current height.

var $grid = $('#grid');
$grid.height( $grid.height() ); // fix the height at its current height

$('#grid').masonry({ columnWidth:250, itemSelector:".awallpost", animate:false, resizeable:false });

If this causes problems during initial loading or in some browsers, try to install .height()only if it is more than a certain amount. Try 0or a small number, for example 250.

var $grid = $('#grid');
var height = $grid.height();

if( height > 0 ) { // or some other number
    $grid.height( height );
}

$('#grid').masonry({ columnWidth:250, itemSelector:".awallpost", animate:false, resizeable:false });

, masonry absolute, top left , , , absolute.

, , masonry , #grid 0, .

, , #grid (, , ) , . masonry(), , absolute.

+8

,

senario

, - http://www.charlotte.com/mld/charlotte/

, -: no-store .

, . , . , , - , , .

, , ?

+1

, , ? ""? BalusC, , , , mr. Chavan, Cache-Control: no-store, , , .

, , HTTP Cache-Control:. (: FF no-store - no-cache HTTPS, IE Cache-Control .)

You can set cache headers either on an HTTP server (Apache, lighttpd, etc.) or in code. Each web address language has its own HTTP header settings, the correct solution to resolve the problem depends on your environment.

This SO post offers some solutions, including some esoteric methods for storing page scroll positions using JS and cookies.

+1
source

Source: https://habr.com/ru/post/1779717/


All Articles