From 18152a9df66e4402789e6b259776060073ba0a1e Mon Sep 17 00:00:00 2001 From: Tereza Lansing <48683000+t-lansing@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:38:56 +0100 Subject: [PATCH] fix(incito): almost respect VideoView autoplay/controls/loop options (#268) * conditional controls when not lazy * refactor --- lib/incito-browser/incito.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/incito-browser/incito.ts b/lib/incito-browser/incito.ts index ddca7637..78627277 100644 --- a/lib/incito-browser/incito.ts +++ b/lib/incito-browser/incito.ts @@ -287,25 +287,24 @@ function renderView(view, canLazyload: boolean, shouldLazyload: boolean) { const src = String(new URL(view.src)); + if (view.autoplay === true) { + attrs['data-autoplay'] = true; + } + + if (view.controls === true) { + attrs['controls'] = ''; + } + + if (view.loop === true) { + attrs['loop'] = ''; + } + if (canLazyload && shouldLazyload) { attrs['data-src'] = `${src}#t=0.1`; attrs['data-mime'] = view.mime; classNames.push('incito--lazy'); - - if (view.autoplay === true) { - attrs['data-autoplay'] = true; - } - - if (view.controls === true) { - attrs['controls'] = ''; - } - - if (view.loop === true) { - attrs['loop'] = ''; - } } else { attrs.src = `${src}#t=0.1`; - attrs.controls = ''; } break;