Skip to content

Conversation

@PolinaShneider
Copy link
Contributor

Lazy-loading module for images & videos

image

Copy link
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Модуль просто дописывает классы, а не осуществляет lazy load

</video>
<? endif; ?>
<div class="lazy-load js_lazy-load">
<? if (strpos($plugin['demo'], 'mp4') === false): ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что находится в поле demo? ссылка? а почему называется demo? но это меньшая проблема.

мало же проверять просто вхождение mp4. надо проверять наличие .mp4 в конце строки

<img class="lazy-load__media js_lazy-media" src="<?= $plugin['demo'] ?>" alt="<?= $plugin['name'] ?>">
<? else: ?>
<video class="lazy-load__media js_lazy-media" autoplay loop muted playsinline>
<source src="<?= $plugin['demo'] ?>" type="video/mp4">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем ты сразу прописываешь src у элемента? идея в том, чтобы не задавать этот параметр сразу. тот же путь к источнику прописывается, например, в data-src, а потом с помощью js подставляется в параметр src. тем самым получается, что эти элементы не тормозят загрузку страницы

/**
* Classes used in module
*/
static get classes() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мы везде этот геттер вроде называем CSS()

*/
addLoadedClass(element) {

element.closest(`.${LazyLoad.classes.wrapper}`).classList.add(LazyLoad.classes.loaded);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

подключи линтер, плиз

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants