A
A
Andrey Nikiforov2018-03-13 17:57:16
JavaScript
Andrey Nikiforov, 2018-03-13 17:57:16

Why is the correct block height immediately considered?

There is a script that more or less replaces Masonry, it just calculates the height of the blocks at certain resolutions and gives the browser what it needs, however, a bug was noticed, if you go to the page for the first time - then it does not do the calculations when you revisit the pages or click on the photo - works as it should

. I give the original site, because for some reason everything works on the codepen, I know that there may be incompatibilities, but how to avoid them and fix the code without spending a lot of time?
Url sbu-73.ru
sbu-73.ru/wp-content/themes/sbu/js/work.js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fl3nkey, 2018-03-13
@FLUNKEY

Because you are counting the height before the image has time to load. The second time it works because the images are taken from the cache, and this is faster than executing the script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question