Ajustes antes de produccion
This commit is contained in:
+130
-25
@@ -60,24 +60,21 @@
|
||||
assign fallback_image = blank
|
||||
case forloop.index
|
||||
when 1
|
||||
assign fallback_image = 'learn-cover-1.avif'
|
||||
assign fallback_image = 'video-11.png'
|
||||
when 2
|
||||
assign fallback_image = 'learn-cover-2.avif'
|
||||
assign fallback_image = 'video-22.png'
|
||||
when 3
|
||||
assign fallback_image = 'reel1.jpg'
|
||||
assign fallback_image = 'learn-reel-3.avif'
|
||||
when 4
|
||||
assign fallback_image = 'learn-cover-4.avif'
|
||||
assign fallback_image = 'video-44.png'
|
||||
when 5
|
||||
assign fallback_image = 'learn-cover-5.avif'
|
||||
assign fallback_image = 'video-55.png'
|
||||
endcase
|
||||
|
||||
assign poster_alt = heading
|
||||
assign slide_state = ''
|
||||
if forloop.index0 == active_index
|
||||
assign slide_state = ' is-active'
|
||||
if video_src != blank
|
||||
assign slide_state = slide_state | append: ' is-playing'
|
||||
endif
|
||||
endif
|
||||
%}
|
||||
<article
|
||||
@@ -103,10 +100,12 @@
|
||||
src="{{ fallback_image | asset_url }}"
|
||||
alt="{{ poster_alt | escape }}"
|
||||
width="384"
|
||||
height="680"
|
||||
height="{% if fallback_image contains '.png' %}518{% else %}680{% endif %}"
|
||||
loading="lazy"
|
||||
srcset="{{ fallback_image | replace: '.avif', '-sm.avif' | asset_url }} 400w, {{ fallback_image | asset_url }} 780w"
|
||||
sizes="(max-width: 1024px) 220px, 384px"
|
||||
{% unless fallback_image contains '.png' %}
|
||||
srcset="{{ fallback_image | replace: '.avif', '-sm.avif' | asset_url }} 360w, {{ fallback_image | asset_url }} 720w"
|
||||
sizes="(max-width: 1024px) 200px, 384px"
|
||||
{% endunless %}
|
||||
decoding="async"
|
||||
>
|
||||
{% endif %}
|
||||
@@ -114,23 +113,20 @@
|
||||
<video
|
||||
class="learn__video"
|
||||
data-learn-video
|
||||
src="{{ video_src }}"
|
||||
data-src="{{ video_src }}"
|
||||
{% if block.settings.poster != blank %}
|
||||
poster="{{ block.settings.poster | image_url: width: 800 }}"
|
||||
{% elsif fallback_image != blank %}
|
||||
poster="{{ fallback_image | asset_url }}"
|
||||
{% endif %}
|
||||
muted
|
||||
playsinline
|
||||
loop
|
||||
{% if forloop.index0 == active_index %}
|
||||
autoplay
|
||||
preload="auto"
|
||||
{% else %}
|
||||
preload="none"
|
||||
{% endif %}
|
||||
preload="none"
|
||||
></video>
|
||||
<button class="learn__play" type="button" data-learn-play aria-label="{{ 'learn.play_sound' | t }}">
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" aria-hidden="true" focusable="false"><path d="M7 4.5v13l11-6.5z" fill="currentColor"/></svg>
|
||||
</button>
|
||||
<button class="learn__sound" type="button" data-learn-sound aria-pressed="false" aria-label="{{ 'learn.sound_on' | t }}" data-label-on="{{ 'learn.sound_on' | t }}" data-label-off="{{ 'learn.sound_off' | t }}">
|
||||
<svg class="learn__sound-off" width="18" height="18" viewBox="0 0 18 18" aria-hidden="true" focusable="false"><path d="M3 6.5h2.5L9 3.5v11L5.5 11.5H3z" fill="currentColor"/><path d="M12 6.5l4 5M16 6.5l-4 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
|
||||
<svg class="learn__sound-on" width="18" height="18" viewBox="0 0 18 18" aria-hidden="true" focusable="false"><path d="M3 6.5h2.5L9 3.5v11L5.5 11.5H3z" fill="currentColor"/><path d="M12 6.2a3.6 3.6 0 0 1 0 5.6M14 4.2a6.3 6.3 0 0 1 0 9.6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
|
||||
<span class="learn__sound-text">{{ 'learn.tap_sound' | t }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
@@ -138,6 +134,102 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script nolazy>
|
||||
(function () {
|
||||
if (window.__learnReelClicks) return;
|
||||
window.__learnReelClicks = true;
|
||||
var setSoundUi = function (root) {
|
||||
var on = root.dataset.sound === 'on';
|
||||
root.querySelectorAll('[data-learn-sound]').forEach(function (b) {
|
||||
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
||||
b.setAttribute('aria-label', on ? b.dataset.labelOff : b.dataset.labelOn);
|
||||
});
|
||||
root.classList.toggle('has-sound', on);
|
||||
};
|
||||
var watch = function (slide, video) {
|
||||
if (video.dataset.watched) return;
|
||||
video.dataset.watched = '1';
|
||||
video.addEventListener('playing', function () { slide.classList.add('is-playing'); slide.classList.remove('is-paused'); });
|
||||
video.addEventListener('pause', function () { if (slide.classList.contains('is-active')) slide.classList.add('is-paused'); });
|
||||
};
|
||||
var start = function (root, slide, video) {
|
||||
root.dataset.sound = 'on';
|
||||
setSoundUi(root);
|
||||
if (video.dataset.src && video.getAttribute('src') !== video.dataset.src) { video.src = video.dataset.src; video.load(); }
|
||||
video.dataset.loaded = 'true';
|
||||
video.muted = false;
|
||||
watch(slide, video);
|
||||
slide.classList.add('is-playing');
|
||||
slide.classList.remove('is-paused');
|
||||
var p = video.play();
|
||||
if (p && p.catch) p.catch(function () {
|
||||
video.muted = true;
|
||||
root.dataset.sound = 'off';
|
||||
setSoundUi(root);
|
||||
video.play().catch(function () {});
|
||||
});
|
||||
};
|
||||
// Autoplay (muted) only while the reels are on screen.
|
||||
if ('IntersectionObserver' in window) {
|
||||
var io = new IntersectionObserver(function (entries) {
|
||||
entries.forEach(function (entry) {
|
||||
var root = entry.target;
|
||||
var active = root.querySelector('[data-slide].is-active');
|
||||
var video = active && active.querySelector('[data-learn-video]');
|
||||
if (entry.isIntersecting) {
|
||||
root.dataset.inview = '1';
|
||||
if (video && video.paused && !active.classList.contains('is-paused')) {
|
||||
if (video.dataset.src && video.getAttribute('src') !== video.dataset.src) { video.src = video.dataset.src; video.dataset.loaded = 'true'; }
|
||||
video.muted = root.dataset.sound !== 'on';
|
||||
watch(active, video);
|
||||
var p = video.play(); if (p && p.catch) p.catch(function () {});
|
||||
}
|
||||
} else {
|
||||
root.dataset.inview = '0';
|
||||
if (video && !video.paused) { video.pause(); active.classList.remove('is-paused'); }
|
||||
}
|
||||
});
|
||||
}, { rootMargin: '100px 0px' });
|
||||
var observe = function () { document.querySelectorAll('[data-learn]').forEach(function (r) { io.observe(r); }); };
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', observe); else observe();
|
||||
}
|
||||
document.addEventListener('click', function (event) {
|
||||
// The carousel drag code uses pointer capture, which retargets the click to the viewport.
|
||||
var hit = event.target.closest('[data-learn] .learn__media') ? event.target : document.elementFromPoint(event.clientX, event.clientY);
|
||||
var media = hit && hit.closest('[data-learn] .learn__media');
|
||||
if (media && !event.target.closest('[data-learn]')) media = null;
|
||||
if (!media) return;
|
||||
var root = media.closest('[data-learn]');
|
||||
var slide = media.closest('[data-slide]');
|
||||
var video = slide && slide.querySelector('[data-learn-video]');
|
||||
if (!video) return;
|
||||
event.preventDefault();
|
||||
var slides = [].slice.call(root.querySelectorAll('[data-slide]'));
|
||||
var i = slides.indexOf(slide);
|
||||
if (hit.closest('[data-learn-sound]')) {
|
||||
var on = root.dataset.sound !== 'on';
|
||||
root.dataset.sound = on ? 'on' : 'off';
|
||||
setSoundUi(root);
|
||||
video.muted = !on;
|
||||
if (video.paused) start(root, slide, video);
|
||||
if (!on) video.muted = true;
|
||||
return;
|
||||
}
|
||||
if (!slide.classList.contains('is-active')) {
|
||||
slides.forEach(function (s) { if (s !== slide) { var v = s.querySelector('[data-learn-video]'); if (v) v.pause(); } });
|
||||
start(root, slide, video);
|
||||
if (root.__learnGo) root.__learnGo(i);
|
||||
else {
|
||||
root.dataset.pending = String(i);
|
||||
slides.forEach(function (s) { s.classList.toggle('is-active', s === slide); });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (video.paused || video.muted) start(root, slide, video);
|
||||
else video.pause();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<button class="learn__arrow learn__arrow--prev" type="button" data-learn-prev aria-label="{{ 'learn.previous' | t }}">
|
||||
<span class="learn__arrow-icon" aria-hidden="true">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -165,7 +257,7 @@
|
||||
assign slide_product = block.settings.product_2
|
||||
endif
|
||||
%}
|
||||
{% if slide_product != blank %}
|
||||
{% if slide_product != blank and slide_product.available %}
|
||||
{% liquid
|
||||
assign variant = slide_product.selected_or_first_available_variant
|
||||
assign card_image = slide_product.featured_image
|
||||
@@ -258,7 +350,13 @@
|
||||
|
||||
const playSlide = (slide) => {
|
||||
const video = slide.querySelector('[data-learn-video]');
|
||||
if (!video || reduceMotion) return;
|
||||
if (!video) return;
|
||||
const root = slide.closest('[data-learn]');
|
||||
const soundOn = root && root.dataset.sound === 'on';
|
||||
if (reduceMotion && !soundOn) return;
|
||||
// Only download/play once the section is on screen (or the visitor asked for sound).
|
||||
if (!soundOn && root && root.dataset.inview !== '1') return;
|
||||
video.muted = !soundOn;
|
||||
if (video.dataset.loaded !== 'true' && video.dataset.src) {
|
||||
video.dataset.loaded = 'true';
|
||||
if (video.getAttribute('src') !== video.dataset.src) {
|
||||
@@ -276,6 +374,7 @@
|
||||
const stopSlide = (slide) => {
|
||||
const video = slide.querySelector('[data-learn-video]');
|
||||
slide.classList.remove('is-playing');
|
||||
slide.classList.remove('is-paused');
|
||||
if (video && video.dataset.loaded === 'true') video.pause();
|
||||
};
|
||||
|
||||
@@ -329,6 +428,7 @@
|
||||
index = target;
|
||||
paint(true);
|
||||
};
|
||||
root.__learnGo = go;
|
||||
|
||||
prev?.addEventListener('click', () => go(index - 1));
|
||||
next?.addEventListener('click', () => go(index + 1));
|
||||
@@ -416,6 +516,10 @@
|
||||
}
|
||||
|
||||
window.addEventListener('resize', () => paint(false));
|
||||
if (root.dataset.pending) {
|
||||
index = Math.min(Math.max(Number(root.dataset.pending) || 0, 0), slides.length - 1);
|
||||
delete root.dataset.pending;
|
||||
}
|
||||
paint(false);
|
||||
};
|
||||
|
||||
@@ -431,6 +535,7 @@
|
||||
if (!window.__seasonLearn) {
|
||||
window.__seasonLearn = true;
|
||||
document.addEventListener('submit', async (event) => {
|
||||
if (event.defaultPrevented) return;
|
||||
const form = event.target;
|
||||
if (!(form instanceof HTMLFormElement) || !form.classList.contains('learn__form')) return;
|
||||
const root = form.closest('[data-learn]');
|
||||
|
||||
Reference in New Issue
Block a user