presi-slides 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { HtmlBasePlugin } from "@11ty/eleventy";
2
+ import htex from "htex/eleventy";
2
3
  import slideTransform from "./src/11ty-transform.js";
3
4
 
4
5
  const output = process.env.STATIC || "static";
@@ -13,6 +14,7 @@ export default async function (eleventyConfig) {
13
14
  eleventyConfig.addPassthroughCopy("includes");
14
15
 
15
16
  eleventyConfig.addPlugin(HtmlBasePlugin);
17
+ eleventyConfig.addPlugin(htex, {});
16
18
 
17
19
  eleventyConfig.addTransform("slide", slideTransform);
18
20
 
@@ -122,4 +122,4 @@ js: import "konva/skia-backend";
122
122
  transition: opacity 1s;
123
123
  }
124
124
  }
125
- `;isPaint=!1;overlayMode=`pointer`;overlayColor=`red`;stage=null;constructor(){super(),ne(this).template(e.template).styles(e.styles)}static observedAttributes=[`active`,`overlay`];attributeChangedCallback(e,t,n){switch(e){case`overlay`:this.overlayMode=n,this.createOverlay();break;case`color`:this.overlayColor=n}}disconnectedCallback(){this.stage&&delete this.stage}createOverlay(){if(this.stage)return;let e=this.shadowRoot.getElementById(`overlay`);console.log(`Creating overlay if needed`,this.stage),this.stage=new ua.Stage({container:e,width:e?.clientWidth,height:e?.clientHeight}),this.layer=new ua.Layer,this.stage.add(this.layer),this.stage.on(`mousedown touchstart`,e=>{this.isPaint=!0;let t=this.stage.getPointerPosition();console.log(`touchstart`,t),this.lastLine=new ua.Line({stroke:this.overlayColor,strokeWidth:this.overlayMode===`eraser`?20:4,globalCompositeOperation:this.overlayMode===`brush`?`source-over`:`destination-out`,lineCap:`round`,lineJoin:`round`,points:[t.x,t.y,t.x,t.y]}),this.layer.add(this.lastLine)}),this.stage.on(`mouseup touchend`,()=>{this.isPaint=!1,console.log(`touchend`)}),this.stage.on(`mousemove touchmove`,e=>{if(!this.isPaint)return;e.evt.preventDefault();let t=this.stage.getPointerPosition(),n=this.lastLine.points().concat([t.x,t.y]);this.lastLine.points(n)})}},fa=.4,pa=.8,ma=class extends HTMLElement{VIEW_ELEMENT=`slide-view`;FOOTER_ELEMENT=`slide-footer`;controls=null;active=null;observer=new IntersectionObserver(e=>{let t=0,n=null;e.forEach(e=>{if(e.isIntersecting){let r=e.target;e.intersectionRatio<fa?r.removeAttribute(`active`):e.intersectionRatio>t&&(t=e.intersectionRatio,n=r)}}),n&&n!==this.active&&this.setActiveSlide(n)},{threshold:[0,fa,pa,1],delay:300});constructor(){super(),this.addEventListener(`slide:input`,e=>{let{slide:t}=e.detail,n=this.slide(t);this.setActiveSlide(n),this.jumpToSlide(n)}),this.addEventListener(`slide:overlay`,e=>{this.manageOverlay(e.detail)})}slide(e){return Array.from(this.querySelectorAll(this.VIEW_ELEMENT))[e-1]}connectedCallback(){let e=Array.from(this.querySelectorAll(this.VIEW_ELEMENT));this.controls=this.querySelector(this.FOOTER_ELEMENT),e.forEach(e=>this.observer.observe(e))}gotoSlide(e){console.log(`Going to slide`,e),e&&e.scrollIntoView({behavior:`smooth`,block:`center`,inline:`nearest`})}jumpToSlide(e){e&&e.scrollIntoView({block:`center`,inline:`nearest`})}setActiveSlide(e){if(this.active=e,this.active){this.active.setAttribute(`active`,`active`);let t=Array.from(this.querySelectorAll(this.VIEW_ELEMENT)).findIndex(t=>t===e);this.controls&&(this.controls.setAttribute(`slide`,t+1),this.controls.setAttribute(`overlay`,e.getAttribute(`overlay`)||`pointer`))}}manageOverlay(e){let{overlay:t}=e||{};console.log(`Overlay options`,e),this.active&&t&&this.active.setAttribute(`overlay`,t)}};function ha(){window.addEventListener(`resize`,ga),ga()}function ga(){let e=document.body,t=document.documentElement.clientWidth,n=document.documentElement.clientHeight;e.classList.add(`presentation-scaled`),e.style.setProperty(`--viewport-width`,t.toString()),e.style.setProperty(`--viewport-height`,n.toString()),console.log(`Rescaled`,t,n)}c({"slide-presi":ma,"slide-view":da,"slide-footer":T}),ha();
125
+ `;isPaint=!1;overlayMode=`pointer`;overlayColor=`red`;stage=null;constructor(){super(),ne(this).template(e.template).styles(e.styles),te.delegate(this,`.reveal`,{click:e=>{let t=e.target;if(t){let e=t.nextElementSibling;e&&e.classList.add(`reveal`),t.classList.remove(`reveal`)}}}),te.delegate(this,`.reveal ~ :not(.reveal)`,{click:e=>{let t=e.target;t&&t.classList.add(`reveal-one`)}})}static observedAttributes=[`active`,`overlay`];attributeChangedCallback(e,t,n){switch(e){case`overlay`:this.overlayMode=n,this.createOverlay();break;case`color`:this.overlayColor=n}}disconnectedCallback(){this.stage&&delete this.stage}createOverlay(){if(this.stage)return;let e=this.shadowRoot.getElementById(`overlay`);console.log(`Creating overlay if needed`,this.stage),this.stage=new ua.Stage({container:e,width:e?.clientWidth,height:e?.clientHeight}),this.layer=new ua.Layer,this.stage.add(this.layer),this.stage.on(`mousedown touchstart`,e=>{this.isPaint=!0;let t=this.stage.getPointerPosition();console.log(`touchstart`,t),this.lastLine=new ua.Line({stroke:this.overlayColor,strokeWidth:this.overlayMode===`eraser`?20:4,globalCompositeOperation:this.overlayMode===`brush`?`source-over`:`destination-out`,lineCap:`round`,lineJoin:`round`,points:[t.x,t.y,t.x,t.y]}),this.layer.add(this.lastLine)}),this.stage.on(`mouseup touchend`,()=>{this.isPaint=!1,console.log(`touchend`)}),this.stage.on(`mousemove touchmove`,e=>{if(!this.isPaint)return;e.evt.preventDefault();let t=this.stage.getPointerPosition(),n=this.lastLine.points().concat([t.x,t.y]);this.lastLine.points(n)})}},fa=.4,pa=.8,ma=new URLSearchParams(document.location.search),ha=class extends HTMLElement{VIEW_ELEMENT=`slide-view`;FOOTER_ELEMENT=`slide-footer`;controls=null;active=null;observer=new IntersectionObserver(e=>{let t=0,n=null;e.forEach(e=>{if(e.isIntersecting){let r=e.target;e.intersectionRatio<fa?r.removeAttribute(`active`):e.intersectionRatio>t&&(t=e.intersectionRatio,n=r)}}),n&&n!==this.active&&this.setActiveSlide(n)},{threshold:[0,fa,pa,1],delay:300});constructor(){super(),this.addEventListener(`slide:input`,e=>{let{slide:t}=e.detail,n=this.slide(t);this.setActiveSlide(n),this.jumpToSlide(n)}),this.addEventListener(`slide:overlay`,e=>{this.manageOverlay(e.detail)}),ma.get(`reveal`)&&this.classList.add(`reveal-all`)}slide(e){return Array.from(this.querySelectorAll(this.VIEW_ELEMENT))[e-1]}connectedCallback(){let e=Array.from(this.querySelectorAll(this.VIEW_ELEMENT));this.controls=this.querySelector(this.FOOTER_ELEMENT),e.forEach(e=>this.observer.observe(e))}gotoSlide(e){console.log(`Going to slide`,e),e&&e.scrollIntoView({behavior:`smooth`,block:`center`,inline:`nearest`})}jumpToSlide(e){e&&e.scrollIntoView({block:`center`,inline:`nearest`})}setActiveSlide(e){if(this.active=e,this.active){this.active.setAttribute(`active`,`active`);let t=Array.from(this.querySelectorAll(this.VIEW_ELEMENT)).findIndex(t=>t===e);this.controls&&(this.controls.setAttribute(`slide`,t+1),this.controls.setAttribute(`overlay`,e.getAttribute(`overlay`)||`pointer`))}}manageOverlay(e){let{overlay:t}=e||{};console.log(`Overlay options`,e),this.active&&t&&this.active.setAttribute(`overlay`,t)}};function ga(){window.addEventListener(`resize`,_a),_a()}function _a(){let e=document.body,t=document.documentElement.clientWidth,n=document.documentElement.clientHeight;e.classList.add(`presentation-scaled`),e.style.setProperty(`--viewport-width`,t.toString()),e.style.setProperty(`--viewport-height`,n.toString()),console.log(`Rescaled`,t,n)}c({"slide-presi":ha,"slide-view":da,"slide-footer":T}),ga();
@@ -8427,7 +8427,16 @@ var ua = $n.Util._assign($n, {
8427
8427
  overlayColor = "red";
8428
8428
  stage = null;
8429
8429
  constructor() {
8430
- super(), ne(this).template(e.template).styles(e.styles);
8430
+ super(), ne(this).template(e.template).styles(e.styles), te.delegate(this, ".reveal", { click: (e) => {
8431
+ let t = e.target;
8432
+ if (t) {
8433
+ let e = t.nextElementSibling;
8434
+ e && e.classList.add("reveal"), t.classList.remove("reveal");
8435
+ }
8436
+ } }), te.delegate(this, ".reveal ~ :not(.reveal)", { click: (e) => {
8437
+ let t = e.target;
8438
+ t && t.classList.add("reveal-one");
8439
+ } });
8431
8440
  }
8432
8441
  static observedAttributes = ["active", "overlay"];
8433
8442
  attributeChangedCallback(e, t, n) {
@@ -8473,7 +8482,7 @@ var ua = $n.Util._assign($n, {
8473
8482
  this.lastLine.points(n);
8474
8483
  });
8475
8484
  }
8476
- }, fa = .4, pa = .8, ma = class extends HTMLElement {
8485
+ }, fa = .4, pa = .8, ma = new URLSearchParams(document.location.search), ha = class extends HTMLElement {
8477
8486
  VIEW_ELEMENT = "slide-view";
8478
8487
  FOOTER_ELEMENT = "slide-footer";
8479
8488
  controls = null;
@@ -8501,7 +8510,7 @@ var ua = $n.Util._assign($n, {
8501
8510
  this.setActiveSlide(n), this.jumpToSlide(n);
8502
8511
  }), this.addEventListener("slide:overlay", (e) => {
8503
8512
  this.manageOverlay(e.detail);
8504
- });
8513
+ }), ma.get("reveal") && this.classList.add("reveal-all");
8505
8514
  }
8506
8515
  slide(e) {
8507
8516
  return Array.from(this.querySelectorAll(this.VIEW_ELEMENT))[e - 1];
@@ -8537,16 +8546,16 @@ var ua = $n.Util._assign($n, {
8537
8546
  };
8538
8547
  //#endregion
8539
8548
  //#region src/slides.js
8540
- function ha() {
8541
- window.addEventListener("resize", ga), ga();
8542
- }
8543
8549
  function ga() {
8550
+ window.addEventListener("resize", _a), _a();
8551
+ }
8552
+ function _a() {
8544
8553
  let e = document.body, t = document.documentElement.clientWidth, n = document.documentElement.clientHeight;
8545
8554
  e.classList.add("presentation-scaled"), e.style.setProperty("--viewport-width", t.toString()), e.style.setProperty("--viewport-height", n.toString()), console.log("Rescaled", t, n);
8546
8555
  }
8547
8556
  c({
8548
- "slide-presi": ma,
8557
+ "slide-presi": ha,
8549
8558
  "slide-view": da,
8550
8559
  "slide-footer": T
8551
- }), ha();
8560
+ }), ga();
8552
8561
  //#endregion