D
D
De-122020-08-12 17:26:29
AJAX
De-12, 2020-08-12 17:26:29

Ajax loading of goods by the "Load more" button - how to remove the drop down?

Greetings.

The site is loading goods using the "Download more" button, after clicking it, everything loads perfectly, the goods are shown, but the screen jumps down to the level of the button itself, i.e. downloaded products remain at the top and you need to scroll up.

I can't figure out how to make the products load down and the screen doesn't twitch down.

Script attached: https://yadi.sk/d/iZ2M2EjQyhXGsw

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2020-08-12
@Eridani

I won't watch the script.
At the very beginning of the function of clicking on the "load more" button, you need to get a variable that calculates the height from the beginning of the page to the container with goods + the height of the container with goods, and in saxes scroll to these coordinates, roughly speaking like this:

var topoffset = $('.товарыблок').offset().top + $('.товарыблок').height();

In this case, the scroll will occur to the place that was considered the end in the container before the appearance of new goods loaded by Ajax... If you don’t need any jumps at all, look for scrollTop in the code and delete

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question