fixed problem that gallery does not initialize, if element is not visible