presenter 0.1.1
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.
- package/.husky/pre-commit +1 -0
- package/.prettierrc +1 -0
- package/README.md +3 -0
- package/dist/presenter.js +1 -0
- package/examples/README.md +23 -0
- package/examples/simple/dist/index.html +8 -0
- package/examples/simple/package-lock.json +3754 -0
- package/examples/simple/package.json +18 -0
- package/examples/simple/src/index.ts +20 -0
- package/examples/simple/tsconfig.json +10 -0
- package/examples/simple/webpack.config.js +25 -0
- package/package.json +38 -0
- package/src/index.ts +16 -0
- package/src/objects/image.ts +55 -0
- package/src/objects/rectangle.ts +53 -0
- package/src/objects/text.ts +79 -0
- package/src/presentation/object.ts +190 -0
- package/src/presentation/presentation.ts +299 -0
- package/src/presentation/slide.ts +52 -0
- package/src/presentation/theme.ts +3 -0
- package/src/themes/default.ts +7 -0
- package/src/themes/index.ts +1 -0
- package/src/util/position.ts +21 -0
- package/tsconfig.json +12 -0
- package/webpack.config.js +32 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Presenter=n():t.Presenter=n()}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{BoundingBox:()=>r,DefaultTheme:()=>e,Image:()=>pt,Presentation:()=>i,Rectangle:()=>wt,Slide:()=>a,SlideObject:()=>lt,Text:()=>vt});const e={backgroundColor:"#ffffff"};var r=function(){function t(t,n,e){this.origin=t,this.width=n,this.height=e}return t.fromElement=function(n){var e=n.getBBox();return new t({x:e.x,y:e.y},e.width,e.height)},t}(),o=function(){return o=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},o.apply(this,arguments)},i=function(){function t(t,n,i,a){if(void 0===a&&(a={}),null===this.element)throw new Error("Presentation cannot be mounted to null element.");this.title=t,this.element=i,this.slides=n,this.options=o({width:3840,height:2160,theme:e},a),this.presentationState={currentSlide:0},this.boundingBox=new r({x:0,y:0},this.options.width,this.options.height),this.container=null,this.svg=null,this.shadow=null}return t.prototype.present=function(){var t=this;this.container=document.createElement("div"),this.container.style.width="100%",this.container.style.aspectRatio="".concat(this.options.width," / ").concat(this.options.height),this.container.style.position="relative",this.container.style.top="50%",this.container.style.transform="translateY(-50%)",this.container.style.marginLeft="auto",this.container.style.marginRight="auto",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.backgroundColor=this.options.theme.backgroundColor,this.svg.style.cursor="none";var n=this.isFullBodyPresentation()?document.body:this.svg;n.addEventListener("keyup",(function(n){"ArrowRight"===n.key||" "===n.key?t.next():"ArrowLeft"===n.key&&t.previous()})),n.addEventListener("mousemove",(function(n){t.svg.style.cursor="auto"})),this.shadow=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.shadow.style.visibility="hidden",[this.svg,this.shadow].forEach((function(n){n.setAttribute("width","100%"),n.setAttribute("viewBox","0 0 ".concat(t.options.width," ").concat(t.options.height)),n.style.position="absolute"})),this.isFullBodyPresentation()&&(document.title=this.title,document.documentElement.style.height="100%",document.body.style.height="100%",document.body.style.width="100%",document.body.style.margin="0",document.body.style.backgroundColor="#000000",window.matchMedia("(min-aspect-ratio: ".concat(this.options.width," / ").concat(this.options.height,")")).addEventListener("change",this.updateSVGContainerSize.bind(this)),this.updateSVGContainerSize()),this.container.appendChild(this.shadow),this.container.appendChild(this.svg),this.element.appendChild(this.container),this.presentationState.currentSlide=0;var e=this.slides[this.presentationState.currentSlide];void 0!==e&&e.render(this)},t.prototype.updateSVGContainerSize=function(){window.innerHeight/window.innerWidth>this.options.height/this.options.width?(this.container.style.width="100%",this.container.style.height="auto"):(this.container.style.width="auto",this.container.style.height="100%")},t.prototype.next=function(){this.svg.style.cursor="none";var t=this.slides[this.presentationState.currentSlide];if(void 0!==t&&!t.nextAnimation(this)){this.presentationState.currentSlide++;var n=this.slides[this.presentationState.currentSlide];if(void 0===n)return;n.render(this)}},t.prototype.previous=function(){this.svg.style.cursor="none";var t=this.slides[this.presentationState.currentSlide];if(void 0!==t){if(t.animationIndex>0)return t.animationIndex=0,void t.render(this);if(0!==this.presentationState.currentSlide){this.presentationState.currentSlide--;var n=this.slides[this.presentationState.currentSlide];void 0!==n&&n.render(this)}}else{this.presentationState.currentSlide=this.slides.length-1;var e=this.slides[this.presentationState.currentSlide];if(void 0===e)return;e.render(this)}},t.prototype.isFullBodyPresentation=function(){return this.element===document.body},t.prototype.theme=function(){return this.options.theme},t.prototype.computeRenderedBoundingBox=function(t){var n=t.cloneNode(!0);this.shadow.appendChild(n);var e=r.fromElement(n);return this.shadow.removeChild(n),e},t}(),a=function(){function t(t,n){void 0===n&&(n=[]),this.objects=t.filter((function(t){return null!==t})),this.animations=n,this.animationIndex=0}return t.prototype.render=function(t){t.svg.innerHTML="",this.animationIndex=0,this.objects.forEach((function(n){n._element=n.generate(t),t.svg.appendChild(n.element())}))},t.prototype.nextAnimation=function(t){var n=this.animations[this.animationIndex];return!!n&&(n(t),this.animationIndex++,!0)},t.prototype.sleep=function(t){return n=this,e=void 0,o=function(){return function(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(t,i)}catch(t){u=[6,t],r=0}finally{e=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(n){return[2,new Promise((function(n){return setTimeout(n,t)}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function u(t){try{s(o.throw(t))}catch(t){i(t)}}function s(n){var e;n.done?t(n.value):(e=n.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((o=o.apply(n,e||[])).next())}));var n,e,r,o},t}(),u={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},s={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},c=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],l={CSS:{},springs:{}};function f(t,n,e){return Math.min(Math.max(t,n),e)}function h(t,n){return t.indexOf(n)>-1}function p(t,n){return t.apply(null,n)}var d={arr:function(t){return Array.isArray(t)},obj:function(t){return h(Object.prototype.toString.call(t),"Object")},pth:function(t){return d.obj(t)&&t.hasOwnProperty("totalLength")},svg:function(t){return t instanceof SVGElement},inp:function(t){return t instanceof HTMLInputElement},dom:function(t){return t.nodeType||d.svg(t)},str:function(t){return"string"==typeof t},fnc:function(t){return"function"==typeof t},und:function(t){return void 0===t},nil:function(t){return d.und(t)||null===t},hex:function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},rgb:function(t){return/^rgb/.test(t)},hsl:function(t){return/^hsl/.test(t)},col:function(t){return d.hex(t)||d.rgb(t)||d.hsl(t)},key:function(t){return!u.hasOwnProperty(t)&&!s.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function g(t){var n=/\(([^)]+)\)/.exec(t);return n?n[1].split(",").map((function(t){return parseFloat(t)})):[]}function v(t,n){var e=g(t),r=f(d.und(e[0])?1:e[0],.1,100),o=f(d.und(e[1])?100:e[1],.1,100),i=f(d.und(e[2])?10:e[2],.1,100),a=f(d.und(e[3])?0:e[3],.1,100),u=Math.sqrt(o/r),s=i/(2*Math.sqrt(o*r)),c=s<1?u*Math.sqrt(1-s*s):0,h=s<1?(s*u-a)/c:-a+u;function p(t){var e=n?n*t/1e3:t;return e=s<1?Math.exp(-e*s*u)*(1*Math.cos(c*e)+h*Math.sin(c*e)):(1+h*e)*Math.exp(-e*u),0===t||1===t?t:1-e}return n?p:function(){var n=l.springs[t];if(n)return n;for(var e=1/6,r=0,o=0;;)if(1===p(r+=e)){if(++o>=16)break}else o=0;var i=r*e*1e3;return l.springs[t]=i,i}}function y(t){return void 0===t&&(t=10),function(n){return Math.ceil(f(n,1e-6,1)*t)*(1/t)}}var m,w,b=function(){var t=.1;function n(t,n){return 1-3*n+3*t}function e(t,n){return 3*n-6*t}function r(t){return 3*t}function o(t,o,i){return((n(o,i)*t+e(o,i))*t+r(o))*t}function i(t,o,i){return 3*n(o,i)*t*t+2*e(o,i)*t+r(o)}return function(n,e,r,a){if(0<=n&&n<=1&&0<=r&&r<=1){var u=new Float32Array(11);if(n!==e||r!==a)for(var s=0;s<11;++s)u[s]=o(s*t,n,r);return function(s){return n===e&&r===a||0===s||1===s?s:o(function(e){for(var a=0,s=1;10!==s&&u[s]<=e;++s)a+=t;--s;var c=a+(e-u[s])/(u[s+1]-u[s])*t,l=i(c,n,r);return l>=.001?function(t,n,e,r){for(var a=0;a<4;++a){var u=i(n,e,r);if(0===u)return n;n-=(o(n,e,r)-t)/u}return n}(e,c,n,r):0===l?c:function(t,n,e,r,i){var a,u,s=0;do{(a=o(u=n+(e-n)/2,r,i)-t)>0?e=u:n=u}while(Math.abs(a)>1e-7&&++s<10);return u}(e,a,a+t,n,r)}(s),e,a)}}}}(),x=(m={linear:function(){return function(t){return t}}},w={Sine:function(){return function(t){return 1-Math.cos(t*Math.PI/2)}},Expo:function(){return function(t){return t?Math.pow(2,10*t-10):0}},Circ:function(){return function(t){return 1-Math.sqrt(1-t*t)}},Back:function(){return function(t){return t*t*(3*t-2)}},Bounce:function(){return function(t){for(var n,e=4;t<((n=Math.pow(2,--e))-1)/11;);return 1/Math.pow(4,3-e)-7.5625*Math.pow((3*n-2)/22-t,2)}},Elastic:function(t,n){void 0===t&&(t=1),void 0===n&&(n=.5);var e=f(t,1,10),r=f(n,.1,2);return function(t){return 0===t||1===t?t:-e*Math.pow(2,10*(t-1))*Math.sin((t-1-r/(2*Math.PI)*Math.asin(1/e))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint"].forEach((function(t,n){w[t]=function(){return function(t){return Math.pow(t,n+2)}}})),Object.keys(w).forEach((function(t){var n=w[t];m["easeIn"+t]=n,m["easeOut"+t]=function(t,e){return function(r){return 1-n(t,e)(1-r)}},m["easeInOut"+t]=function(t,e){return function(r){return r<.5?n(t,e)(2*r)/2:1-n(t,e)(-2*r+2)/2}},m["easeOutIn"+t]=function(t,e){return function(r){return r<.5?(1-n(t,e)(1-2*r))/2:(n(t,e)(2*r-1)+1)/2}}})),m);function O(t,n){if(d.fnc(t))return t;var e=t.split("(")[0],r=x[e],o=g(t);switch(e){case"spring":return v(t,n);case"cubicBezier":return p(b,o);case"steps":return p(y,o);default:return p(r,o)}}function S(t){try{return document.querySelectorAll(t)}catch(t){return}}function P(t,n){for(var e=t.length,r=arguments.length>=2?arguments[1]:void 0,o=[],i=0;i<e;i++)if(i in t){var a=t[i];n.call(r,a,i,t)&&o.push(a)}return o}function M(t){return t.reduce((function(t,n){return t.concat(d.arr(n)?M(n):n)}),[])}function B(t){return d.arr(t)?t:(d.str(t)&&(t=S(t)||t),t instanceof NodeList||t instanceof HTMLCollection?[].slice.call(t):[t])}function j(t,n){return t.some((function(t){return t===n}))}function A(t){var n={};for(var e in t)n[e]=t[e];return n}function C(t,n){var e=A(t);for(var r in t)e[r]=n.hasOwnProperty(r)?n[r]:t[r];return e}function E(t,n){var e=A(t);for(var r in n)e[r]=d.und(t[r])?n[r]:t[r];return e}function k(t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(t);if(n)return n[1]}function I(t,n){return d.fnc(t)?t(n.target,n.id,n.total):t}function _(t,n){return t.getAttribute(n)}function T(t,n,e){if(j([e,"deg","rad","turn"],k(n)))return n;var r=l.CSS[n+e];if(!d.und(r))return r;var o=document.createElement(t.tagName),i=t.parentNode&&t.parentNode!==document?t.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+e;var a=100/o.offsetWidth;i.removeChild(o);var u=a*parseFloat(n);return l.CSS[n+e]=u,u}function D(t,n,e){if(n in t.style){var r=n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=t.style[n]||getComputedStyle(t).getPropertyValue(r)||"0";return e?T(t,o,e):o}}function F(t,n){return d.dom(t)&&!d.inp(t)&&(!d.nil(_(t,n))||d.svg(t)&&t[n])?"attribute":d.dom(t)&&j(c,n)?"transform":d.dom(t)&&"transform"!==n&&D(t,n)?"css":null!=t[n]?"object":void 0}function N(t){if(d.dom(t)){for(var n,e=t.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;n=r.exec(e);)o.set(n[1],n[2]);return o}}function L(t,n,e,r){switch(F(t,n)){case"transform":return function(t,n,e,r){var o=h(n,"scale")?1:0+function(t){return h(t,"translate")||"perspective"===t?"px":h(t,"rotate")||h(t,"skew")?"deg":void 0}(n),i=N(t).get(n)||o;return e&&(e.transforms.list.set(n,i),e.transforms.last=n),r?T(t,i,r):i}(t,n,r,e);case"css":return D(t,n,e);case"attribute":return _(t,n);default:return t[n]||0}}function q(t,n){var e=/^(\*=|\+=|-=)/.exec(t);if(!e)return t;var r=k(t)||0,o=parseFloat(n),i=parseFloat(t.replace(e[0],""));switch(e[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function z(t,n){if(d.col(t))return function(t){return d.rgb(t)?(e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n=t))?"rgba("+e[1]+",1)":n:d.hex(t)?function(t){var n=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,n,e,r){return n+n+e+e+r+r})),e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return"rgba("+parseInt(e[1],16)+","+parseInt(e[2],16)+","+parseInt(e[3],16)+",1)"}(t):d.hsl(t)?function(t){var n,e,r,o=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t),i=parseInt(o[1],10)/360,a=parseInt(o[2],10)/100,u=parseInt(o[3],10)/100,s=o[4]||1;function c(t,n,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+6*(n-t)*e:e<.5?n:e<2/3?t+(n-t)*(2/3-e)*6:t}if(0==a)n=e=r=u;else{var l=u<.5?u*(1+a):u+a-u*a,f=2*u-l;n=c(f,l,i+1/3),e=c(f,l,i),r=c(f,l,i-1/3)}return"rgba("+255*n+","+255*e+","+255*r+","+s+")"}(t):void 0;var n,e}(t);if(/\s/g.test(t))return t;var e=k(t),r=e?t.substr(0,t.length-e.length):t;return n?r+n:r}function H(t,n){return Math.sqrt(Math.pow(n.x-t.x,2)+Math.pow(n.y-t.y,2))}function R(t){for(var n,e=t.points,r=0,o=0;o<e.numberOfItems;o++){var i=e.getItem(o);o>0&&(r+=H(n,i)),n=i}return r}function V(t){if(t.getTotalLength)return t.getTotalLength();switch(t.tagName.toLowerCase()){case"circle":return function(t){return 2*Math.PI*_(t,"r")}(t);case"rect":return function(t){return 2*_(t,"width")+2*_(t,"height")}(t);case"line":return function(t){return H({x:_(t,"x1"),y:_(t,"y1")},{x:_(t,"x2"),y:_(t,"y2")})}(t);case"polyline":return R(t);case"polygon":return function(t){var n=t.points;return R(t)+H(n.getItem(n.numberOfItems-1),n.getItem(0))}(t)}}function G(t,n){var e=n||{},r=e.el||function(t){for(var n=t.parentNode;d.svg(n)&&d.svg(n.parentNode);)n=n.parentNode;return n}(t),o=r.getBoundingClientRect(),i=_(r,"viewBox"),a=o.width,u=o.height,s=e.viewBox||(i?i.split(" "):[0,0,a,u]);return{el:r,viewBox:s,x:s[0]/1,y:s[1]/1,w:a,h:u,vW:s[2],vH:s[3]}}function W(t,n,e){function r(e){void 0===e&&(e=0);var r=n+e>=1?n+e:0;return t.el.getPointAtLength(r)}var o=G(t.el,t.svg),i=r(),a=r(-1),u=r(1),s=e?1:o.w/o.vW,c=e?1:o.h/o.vH;switch(t.property){case"x":return(i.x-o.x)*s;case"y":return(i.y-o.y)*c;case"angle":return 180*Math.atan2(u.y-a.y,u.x-a.x)/Math.PI}}function $(t,n){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=z(d.pth(t)?t.totalLength:t,n)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:d.str(t)||n?r.split(e):[]}}function Y(t){return P(t?M(d.arr(t)?t.map(B):B(t)):[],(function(t,n,e){return e.indexOf(t)===n}))}function X(t){var n=Y(t);return n.map((function(t,e){return{target:t,id:e,total:n.length,transforms:{list:N(t)}}}))}function Z(t,n){var e=A(n);if(/^spring/.test(e.easing)&&(e.duration=v(e.easing)),d.arr(t)){var r=t.length;2!==r||d.obj(t[0])?d.fnc(n.duration)||(e.duration=n.duration/r):t={value:t}}var o=d.arr(t)?t:[t];return o.map((function(t,e){var r=d.obj(t)&&!d.pth(t)?t:{value:t};return d.und(r.delay)&&(r.delay=e?0:n.delay),d.und(r.endDelay)&&(r.endDelay=e===o.length-1?n.endDelay:0),r})).map((function(t){return E(t,e)}))}var Q={css:function(t,n,e){return t.style[n]=e},attribute:function(t,n,e){return t.setAttribute(n,e)},object:function(t,n,e){return t[n]=e},transform:function(t,n,e,r,o){if(r.list.set(n,e),n===r.last||o){var i="";r.list.forEach((function(t,n){i+=n+"("+t+") "})),t.style.transform=i}}};function J(t,n){X(t).forEach((function(t){for(var e in n){var r=I(n[e],t),o=t.target,i=k(r),a=L(o,e,i,t),u=q(z(r,i||k(a)),a),s=F(o,e);Q[s](o,e,u,t.transforms,!0)}}))}function K(t,n){return P(M(t.map((function(t){return n.map((function(n){return function(t,n){var e=F(t.target,n.name);if(e){var r=function(t,n){var e;return t.tweens.map((function(r){var o=function(t,n){var e={};for(var r in t){var o=I(t[r],n);d.arr(o)&&1===(o=o.map((function(t){return I(t,n)}))).length&&(o=o[0]),e[r]=o}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}(r,n),i=o.value,a=d.arr(i)?i[1]:i,u=k(a),s=L(n.target,t.name,u,n),c=e?e.to.original:s,l=d.arr(i)?i[0]:c,f=k(l)||k(s),h=u||f;return d.und(a)&&(a=c),o.from=$(l,h),o.to=$(q(a,l),h),o.start=e?e.end:0,o.end=o.start+o.delay+o.duration+o.endDelay,o.easing=O(o.easing,o.duration),o.isPath=d.pth(i),o.isPathTargetInsideSVG=o.isPath&&d.svg(n.target),o.isColor=d.col(o.from.original),o.isColor&&(o.round=1),e=o,o}))}(n,t),o=r[r.length-1];return{type:e,property:n.name,animatable:t,tweens:r,duration:o.end,delay:r[0].delay,endDelay:o.endDelay}}}(t,n)}))}))),(function(t){return!d.und(t)}))}function U(t,n){var e=t.length,r=function(t){return t.timelineOffset?t.timelineOffset:0},o={};return o.duration=e?Math.max.apply(Math,t.map((function(t){return r(t)+t.duration}))):n.duration,o.delay=e?Math.min.apply(Math,t.map((function(t){return r(t)+t.delay}))):n.delay,o.endDelay=e?o.duration-Math.max.apply(Math,t.map((function(t){return r(t)+t.duration-t.endDelay}))):n.endDelay,o}var tt=0,nt=[],et=function(){var t;function n(e){for(var r=nt.length,o=0;o<r;){var i=nt[o];i.paused?(nt.splice(o,1),r--):(i.tick(e),o++)}t=o>0?requestAnimationFrame(n):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){ot.suspendWhenDocumentHidden&&(rt()?t=cancelAnimationFrame(t):(nt.forEach((function(t){return t._onDocumentVisibility()})),et()))})),function(){t||rt()&&ot.suspendWhenDocumentHidden||!(nt.length>0)||(t=requestAnimationFrame(n))}}();function rt(){return!!document&&document.hidden}function ot(t){void 0===t&&(t={});var n,e=0,r=0,o=0,i=0,a=null;function c(t){var n=window.Promise&&new Promise((function(t){return a=t}));return t.finished=n,n}var l=function(t){var n=C(u,t),e=C(s,t),r=function(t,n){var e=[],r=n.keyframes;for(var o in r&&(n=E(function(t){for(var n=P(M(t.map((function(t){return Object.keys(t)}))),(function(t){return d.key(t)})).reduce((function(t,n){return t.indexOf(n)<0&&t.push(n),t}),[]),e={},r=function(r){var o=n[r];e[o]=t.map((function(t){var n={};for(var e in t)d.key(e)?e==o&&(n.value=t[e]):n[e]=t[e];return n}))},o=0;o<n.length;o++)r(o);return e}(r),n)),n)d.key(o)&&e.push({name:o,tweens:Z(n[o],t)});return e}(e,t),o=X(t.targets),i=K(o,r),a=U(i,e),c=tt;return tt++,E(n,{id:c,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(t);function h(){var t=l.direction;"alternate"!==t&&(l.direction="normal"!==t?"normal":"reverse"),l.reversed=!l.reversed,n.forEach((function(t){return t.reversed=l.reversed}))}function p(t){return l.reversed?l.duration-t:t}function g(){e=0,r=p(l.currentTime)*(1/ot.speed)}function v(t,n){n&&n.seek(t-n.timelineOffset)}function y(t){for(var n=0,e=l.animations,r=e.length;n<r;){var o=e[n],i=o.animatable,a=o.tweens,u=a.length-1,s=a[u];u&&(s=P(a,(function(n){return t<n.end}))[0]||s);for(var c=f(t-s.start-s.delay,0,s.duration)/s.duration,h=isNaN(c)?1:s.easing(c),p=s.to.strings,d=s.round,g=[],v=s.to.numbers.length,y=void 0,m=0;m<v;m++){var w=void 0,b=s.to.numbers[m],x=s.from.numbers[m]||0;w=s.isPath?W(s.value,h*b,s.isPathTargetInsideSVG):x+h*(b-x),d&&(s.isColor&&m>2||(w=Math.round(w*d)/d)),g.push(w)}var O=p.length;if(O){y=p[0];for(var S=0;S<O;S++){p[S];var M=p[S+1],B=g[S];isNaN(B)||(y+=M?B+M:B+" ")}}else y=g[0];Q[o.type](i.target,o.property,y,i.transforms),o.currentValue=y,n++}}function m(t){l[t]&&!l.passThrough&&l[t](l)}function w(t){var u=l.duration,s=l.delay,d=u-l.endDelay,g=p(t);l.progress=f(g/u*100,0,100),l.reversePlayback=g<l.currentTime,n&&function(t){if(l.reversePlayback)for(var e=i;e--;)v(t,n[e]);else for(var r=0;r<i;r++)v(t,n[r])}(g),!l.began&&l.currentTime>0&&(l.began=!0,m("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,m("loopBegin")),g<=s&&0!==l.currentTime&&y(0),(g>=d&&l.currentTime!==u||!u)&&y(u),g>s&&g<d?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,m("changeBegin")),m("change"),y(g)):l.changeBegan&&(l.changeCompleted=!0,l.changeBegan=!1,m("changeComplete")),l.currentTime=f(g,0,u),l.began&&m("update"),t>=u&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(e=o,m("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&h()):(l.paused=!0,l.completed||(l.completed=!0,m("loopComplete"),m("complete"),!l.passThrough&&"Promise"in window&&(a(),c(l)))))}return c(l),l.reset=function(){var t=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===t,l.remaining=l.loop,n=l.children;for(var e=i=n.length;e--;)l.children[e].reset();(l.reversed&&!0!==l.loop||"alternate"===t&&1===l.loop)&&l.remaining++,y(l.reversed?l.duration:0)},l._onDocumentVisibility=g,l.set=function(t,n){return J(t,n),l},l.tick=function(t){o=t,e||(e=o),w((o+(r-e))*ot.speed)},l.seek=function(t){w(p(t))},l.pause=function(){l.paused=!0,g()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,nt.push(l),g(),et())},l.reverse=function(){h(),l.completed=!l.reversed,g()},l.restart=function(){l.reset(),l.play()},l.remove=function(t){at(Y(t),l)},l.reset(),l.autoplay&&l.play(),l}function it(t,n){for(var e=n.length;e--;)j(t,n[e].animatable.target)&&n.splice(e,1)}function at(t,n){var e=n.animations,r=n.children;it(t,e);for(var o=r.length;o--;){var i=r[o],a=i.animations;it(t,a),a.length||i.children.length||r.splice(o,1)}e.length||r.length||n.pause()}ot.version="3.2.1",ot.speed=1,ot.suspendWhenDocumentHidden=!0,ot.running=nt,ot.remove=function(t){for(var n=Y(t),e=nt.length;e--;)at(n,nt[e])},ot.get=L,ot.set=J,ot.convertPx=T,ot.path=function(t,n){var e=d.str(t)?S(t)[0]:t,r=n||100;return function(t){return{property:t,el:e,svg:G(e),totalLength:V(e)*(r/100)}}},ot.setDashoffset=function(t){var n=V(t);return t.setAttribute("stroke-dasharray",n),n},ot.stagger=function(t,n){void 0===n&&(n={});var e=n.direction||"normal",r=n.easing?O(n.easing):null,o=n.grid,i=n.axis,a=n.from||0,u="first"===a,s="center"===a,c="last"===a,l=d.arr(t),f=l?parseFloat(t[0]):parseFloat(t),h=l?parseFloat(t[1]):0,p=k(l?t[1]:t)||0,g=n.start||0+(l?f:0),v=[],y=0;return function(t,n,d){if(u&&(a=0),s&&(a=(d-1)/2),c&&(a=d-1),!v.length){for(var m=0;m<d;m++){if(o){var w=s?(o[0]-1)/2:a%o[0],b=s?(o[1]-1)/2:Math.floor(a/o[0]),x=w-m%o[0],O=b-Math.floor(m/o[0]),S=Math.sqrt(x*x+O*O);"x"===i&&(S=-x),"y"===i&&(S=-O),v.push(S)}else v.push(Math.abs(a-m));y=Math.max.apply(Math,v)}r&&(v=v.map((function(t){return r(t/y)*y}))),"reverse"===e&&(v=v.map((function(t){return i?t<0?-1*t:-t:Math.abs(y-t)})))}return g+(l?(h-f)/y:f)*(Math.round(100*v[n])/100)+p}},ot.timeline=function(t){void 0===t&&(t={});var n=ot(t);return n.duration=0,n.add=function(e,r){var o=nt.indexOf(n),i=n.children;function a(t){t.passThrough=!0}o>-1&&nt.splice(o,1);for(var u=0;u<i.length;u++)a(i[u]);var c=E(e,C(s,t));c.targets=c.targets||t.targets;var l=n.duration;c.autoplay=!1,c.direction=n.direction,c.timelineOffset=d.und(r)?l:q(r,l),a(n),n.seek(c.timelineOffset);var f=ot(c);a(f),i.push(f);var h=U(i,t);return n.delay=h.delay,n.endDelay=h.endDelay,n.duration=h.duration,n.seek(0),n.reset(),n.autoplay&&n.play(),n},n},ot.easing=O,ot.penner=x,ot.random=function(t,n){return Math.floor(Math.random()*(n-t+1))+t};const ut=ot;var st,ct=function(){return ct=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ct.apply(this,arguments)},lt=function(){function t(t){this.props=ct({position:null,verticalAnchor:"top",horizontalAnchor:"start"},t),this._element=null}return t.prototype.generate=function(t){return null},t.prototype.element=function(){if(null===this._element)throw new Error("Element not yet generated");return this._element},t.prototype.animate=function(t,n){void 0===n&&(n=null);var e=t.bbox,r=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(t,["bbox"]),o=ct(ct(ct({},r),void 0!==e?this.computePositionAttributes(n,e):{}),"cubic"===t.easing?{easing:"cubicBezier(0.42, 0, 0.58, 1)"}:{});ut(ct({targets:this.element(),duration:500,easing:"linear"},o))},t.prototype.animation=function(t){var n=this;return function(){return n.animate(t)}},t.prototype.animateMove=function(t,n,e){this.animate(ct({x:t.x,y:t.y},n),e)},t.prototype.positionInPresentation=function(t,n,e){return{x:n<=1?n*t.boundingBox.width:n,y:e<=1?e*t.boundingBox.height:e}},t.prototype.anchorBoundingBox=function(t){var n=this.props,e=n.verticalAnchor,o=n.horizontalAnchor,i=function(){switch(e){case"top":return t.origin.y;case"center":return t.origin.y-t.height/2;case"bottom":return t.origin.y-t.height}}(),a=function(){switch(o){case"start":return t.origin.x;case"center":return t.origin.x-t.width/2;case"end":return t.origin.x-t.width}}();return new r({x:a,y:i},t.width,t.height)},t.prototype.computeRenderedBoundingBox=function(t,n,e){void 0===e&&(e=!1);var o=n.computeRenderedBoundingBox(t);return new r({x:this.props.position.x,y:this.props.position.y},o.width,o.height)},t.prototype.computePositionAttributes=function(t,n){if(null===t)throw new Error("Cannot compute object position attributes without presentation");var e=this.positionInPresentation(t,n.origin.x,n.origin.y),o=e.x,i=e.y,a=this.anchorBoundingBox(new r({x:o,y:i},n.width,n.height));return{x:a.origin.x,y:a.origin.y}},t.prototype.setPositionAttributes=function(t,n,e){for(var r=0,o=Object.entries(this.computePositionAttributes(t,n));r<o.length;r++){var i=o[r],a=i[0],u=i[1];e.setAttribute(a,u.toString())}},t}(),ft=(st=function(t,n){return st=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},st(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}st(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),ht=function(){return ht=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ht.apply(this,arguments)},pt=function(t){function n(n){if(void 0===n&&(n={}),!n.href)throw new Error("Image requires a href");return t.call(this,ht({width:100,height:100},n))||this}return ft(n,t),n.prototype.generate=function(t){var n=this.props,e=n.width,o=n.height,i=n.href,a=document.createElementNS("http://www.w3.org/2000/svg","image");return a.setAttribute("href",i),a.setAttribute("width",e.toString()),a.setAttribute("height",o.toString()),this.setPositionAttributes(t,new r(this.props.position,e,o),a),a},n.prototype.animateMove=function(t,n,e){var o=new r(t,this.props.width,this.props.height);this.animate(ht({bbox:o},n),e)},n}(lt),dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),gt=function(){return gt=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},gt.apply(this,arguments)},vt=function(t){function n(n){return void 0===n&&(n={}),t.call(this,gt({color:"#000000",content:"",fontSize:40,fontStyle:"normal",fontFamily:"Arial"},n))||this}return dt(n,t),n.prototype.generate=function(t){var n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.innerHTML=this.props.content,n.style.font="".concat(this.props.fontStyle," ").concat(this.props.fontSize,"px ").concat(this.props.fontFamily),n.style.fill=this.props.color,this.setPositionAttributes(t,this.computeRenderedBoundingBox(n,t,!0),n),n},n.prototype.computePositionAttributes=function(t,n){var e=this.positionInPresentation(t,n.origin.x,n.origin.y),o=e.x,i=e.y,a=this.anchorBoundingBox(new r({x:o,y:i},n.width,n.height));return{x:a.origin.x,y:a.origin.y+n.height}},n.prototype.animateMove=function(t,n,e){var o=this.computeRenderedBoundingBox(this.element(),e,!0),i=new r(t,o.width,o.height);console.log(i),this.animate(gt({bbox:i},n),e)},n}(lt),yt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),mt=function(){return mt=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},mt.apply(this,arguments)},wt=function(t){function n(n){return void 0===n&&(n={}),t.call(this,mt({color:"#000000",width:100,height:100},n))||this}return yt(n,t),n.prototype.generate=function(t){var n=this.props,e=n.width,o=n.height,i=n.color,a=document.createElementNS("http://www.w3.org/2000/svg","rect");return a.setAttribute("fill",i),a.setAttribute("width",e.toString()),a.setAttribute("height",o.toString()),this.setPositionAttributes(t,new r(this.props.position,e,o),a),a},n.prototype.animateMove=function(t,n,e){var o=new r(t,this.props.width,this.props.height);this.animate(mt({bbox:o},n),e)},n}(lt);return n})()));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Example Presenter.js presentations.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
The examples currently require [symlinking the Presenter.js package](https://docs.npmjs.com/cli/v9/commands/npm-link).
|
|
8
|
+
|
|
9
|
+
In the root of this repository, run:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
$ npm link
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then, in each of the examples, e.g. `examples/simple`, run:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ npm link presenter
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This symlinks the local version of the `presenter` package into the example presentation.
|
|
22
|
+
|
|
23
|
+
Then, run the development server with `npm run serve` or build the production version with `npm run build`.
|