Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lazyLoad module #540

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Add lazyLoad module #540

wants to merge 19 commits into from

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.

4 participants