-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: master
Are you sure you want to change the base?
Add lazyLoad module #540
Conversation
There was a problem hiding this 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): ?> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
подключи линтер, плиз
Lazy-loading module for images & videos