diff --git a/opentok-layout.js b/opentok-layout.js index dba4134..321cb2a 100644 --- a/opentok-layout.js +++ b/opentok-layout.js @@ -538,13 +538,24 @@ exports["default"] = (function (opts, elements) { * @Copyright (c) 2014 Adam Ullman * @License: Released under the MIT license (http://opensource.org/licenses/MIT) * */ +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; exports.__esModule = true; // in CommonJS context, this should be a `require()`d dependency. // in browser globals context, ...? (when using bower, there are dependencies that it has handled // for you, so these might be safe to assume) var getLayout_1 = __webpack_require__(0); var layout_1 = __webpack_require__(2); -module.exports = function initLayoutContainer(container, opts) { +module.exports = function initLayoutContainer(container, options) { + var _this = this; + var opts = options; var win = (opts && opts.window) || (typeof window === 'undefined' ? undefined : window); container = typeof container === 'string' ? win.document.querySelector(container) : container; if (!(typeof (win && win.HTMLElement) === 'undefined' || container instanceof win.HTMLElement) && !opts) { @@ -554,9 +565,22 @@ module.exports = function initLayoutContainer(container, opts) { else if (!opts) { opts = {}; } + var setOptions = function (newOptions) { + opts = newOptions; + }; return { - layout: layout_1["default"].bind(this, container, opts), - getLayout: getLayout_1["default"].bind(this, opts) + layout: function () { + return layout_1["default"].apply(_this, [container, opts]); + }, + getLayout: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + console.log('getLayout apply'); + return getLayout_1["default"].apply(_this, __spreadArray([opts], args, true)); + }, + setOptions: setOptions }; }; diff --git a/opentok-layout.min.js b/opentok-layout.min.js index 57c555c..3c4a48e 100644 --- a/opentok-layout.min.js +++ b/opentok-layout.min.js @@ -1,4 +1,4 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.initLayoutContainer=e():t.initLayoutContainer=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)i.d(o,a,function(e){return t[e]}.bind(null,a));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(t,e,i){"use strict";e.__esModule=!0;var o=function(t,e,i,o,a,n,r,h){for(var d,f,l,s,g,c,u,v,p=1;p<=a;p+=1){var m=p,b=Math.ceil(a/m);(v=(u=Math.floor(o/b))/(c=Math.floor(i/m)))>e?u=c*(v=e):v=d){if(h&&w===d&&m*b%a>l*f%a)continue;d=w,s=u,g=c,f=m,l=b}}return{maxArea:d,targetCols:f,targetRows:l,targetHeight:s,targetWidth:g,ratio:s/g}},a=function(t,e){var i,a=t.maxRatio,n=t.minRatio,r=t.fixedRatio,h=t.containerWidth,d=t.containerHeight,f=t.offsetLeft,l=void 0===f?0:f,s=t.offsetTop,g=void 0===s?0:s,c=t.alignItems,u=void 0===c?"center":c,v=t.maxWidth,p=void 0===v?1/0:v,m=t.maxHeight,b=void 0===m?1/0:m,w=t.scaleLastRow,x=void 0===w||w,y=t.evenRows,R=void 0===y||y,M=e.map((function(t){return t.height/t.width})),H=M.length;if(r){var W=M.length>0?M[0]:null;i=o(W,W,h,d,H,p,b,R)}else i=o(n,a,h,d,H,p,b,R);for(var L,_=0,O=0,j=[],T=[],I=0;Ih?(L.height=Math.floor(L.height*(h/L.width)),L.width=h):L.width0){var k=d-A;A=0;for(I=0;I(h-L.width)/L.width&&(q=Math.floor((h-L.width)/L.width*L.height)),L.width+=Math.floor(q/L.height*L.width),L.height+=q,k-=q,E-=1}A+=L.height}}switch(u){case"start":O=0;break;case"end":O=d-A;break;case"center":default:O=(d-A)/2}for(I=0;I0&&at.length>0){var dt=void 0,ft=void 0,lt=!0===R;if(X>(i=ot[0]).height/i.width){if(dt=H,ft=Math.floor(L*g),u>0){var st=void 0;if(p){var gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);ft=Math.max(L*u,Math.min(ft,st.targetHeight*st.targetRows));var ct=a({containerWidth:H,containerHeight:L-ft,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},at),ut=0,vt=void 0;ct.forEach((function(t){vt!==t.top&&(vt=t.top,ut+=t.height)})),ft=Math.max(ft,L-ut)}tt=L-(Z=ft),"column"===R?lt=!1:"row"===R&&(lt=!0)}else{if(ft=L,dt=Math.floor(H*g),u>0){st=void 0;if(p){gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);dt=Math.max(H*u,Math.min(dt,st.targetWidth*st.targetCols));var pt=a({containerWidth:H-dt,containerHeight:L,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},at),mt=0,bt=0,wt=0;pt.forEach((function(t){t.top!==wt&&(bt=0,wt=t.top),bt+=t.width,mt=Math.max(mt,bt)})),dt=Math.max(dt,H-mt)}et=H-(Y=dt),"column"===R?lt=!0:"row"===R&&(lt=!1)}lt?(ht.big={top:0,left:0,width:dt,height:ft},ht.small={top:Z,left:Y,width:H-Y,height:L-Z}):(ht.big={left:et,top:tt,width:dt,height:ft},ht.small={top:0,left:0,width:H-Y,height:L-Z})}else ot.length>0&&0===at.length?ht.big={top:0,left:0,width:H,height:L}:ht.small={top:Z,left:Y,width:H-Y,height:L-Z};ht.big&&(nt=a({containerWidth:ht.big.width,containerHeight:ht.big.height,offsetLeft:ht.big.left,offsetTop:ht.big.top,fixedRatio:p,minRatio:x,maxRatio:b,alignItems:T,maxWidth:z,maxHeight:V,scaleLastRow:K,evenRows:U},ot)),ht.small&&(rt=a({containerWidth:ht.small.width,containerHeight:ht.small.height,offsetLeft:ht.small.left,offsetTop:ht.small.top,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:ht.big?S:O,maxWidth:ht.big?q:P,maxHeight:ht.big?F:E,scaleLastRow:G,evenRows:U},at));var xt=[],yt=0,Rt=0;return e.forEach((function(t,e){it.indexOf(e)>-1?(xt[e]=nt[yt],yt+=1):(xt[e]=rt[Rt],Rt+=1)})),{boxes:xt,areas:ht}}},function(t,e,i){"use strict"; +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.initLayoutContainer=e():t.initLayoutContainer=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(o,n,function(e){return t[e]}.bind(null,n));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(t,e,i){"use strict";e.__esModule=!0;var o=function(t,e,i,o,n,a,r,h){for(var d,f,l,s,g,c,u,v,p=1;p<=n;p+=1){var m=p,b=Math.ceil(n/m);(v=(u=Math.floor(o/b))/(c=Math.floor(i/m)))>e?u=c*(v=e):v=d){if(h&&w===d&&m*b%n>l*f%n)continue;d=w,s=u,g=c,f=m,l=b}}return{maxArea:d,targetCols:f,targetRows:l,targetHeight:s,targetWidth:g,ratio:s/g}},n=function(t,e){var i,n=t.maxRatio,a=t.minRatio,r=t.fixedRatio,h=t.containerWidth,d=t.containerHeight,f=t.offsetLeft,l=void 0===f?0:f,s=t.offsetTop,g=void 0===s?0:s,c=t.alignItems,u=void 0===c?"center":c,v=t.maxWidth,p=void 0===v?1/0:v,m=t.maxHeight,b=void 0===m?1/0:m,w=t.scaleLastRow,x=void 0===w||w,y=t.evenRows,R=void 0===y||y,M=e.map((function(t){return t.height/t.width})),H=M.length;if(r){var W=M.length>0?M[0]:null;i=o(W,W,h,d,H,p,b,R)}else i=o(a,n,h,d,H,p,b,R);for(var L,_=0,O=0,j=[],T=[],I=0;Ih?(L.height=Math.floor(L.height*(h/L.width)),L.width=h):L.width0){var k=d-P;P=0;for(I=0;I(h-L.width)/L.width&&(q=Math.floor((h-L.width)/L.width*L.height)),L.width+=Math.floor(q/L.height*L.width),L.height+=q,k-=q,E-=1}P+=L.height}}switch(u){case"start":O=0;break;case"end":O=d-P;break;case"center":default:O=(d-P)/2}for(I=0;I0&&nt.length>0){var dt=void 0,ft=void 0,lt=!0===R;if(X>(i=ot[0]).height/i.width){if(dt=H,ft=Math.floor(L*g),u>0){var st=void 0;if(p){var gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);ft=Math.max(L*u,Math.min(ft,st.targetHeight*st.targetRows));var ct=n({containerWidth:H,containerHeight:L-ft,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},nt),ut=0,vt=void 0;ct.forEach((function(t){vt!==t.top&&(vt=t.top,ut+=t.height)})),ft=Math.max(ft,L-ut)}tt=L-(Z=ft),"column"===R?lt=!1:"row"===R&&(lt=!0)}else{if(ft=L,dt=Math.floor(H*g),u>0){st=void 0;if(p){gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);dt=Math.max(H*u,Math.min(dt,st.targetWidth*st.targetCols));var pt=n({containerWidth:H-dt,containerHeight:L,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},nt),mt=0,bt=0,wt=0;pt.forEach((function(t){t.top!==wt&&(bt=0,wt=t.top),bt+=t.width,mt=Math.max(mt,bt)})),dt=Math.max(dt,H-mt)}et=H-(Y=dt),"column"===R?lt=!0:"row"===R&&(lt=!1)}lt?(ht.big={top:0,left:0,width:dt,height:ft},ht.small={top:Z,left:Y,width:H-Y,height:L-Z}):(ht.big={left:et,top:tt,width:dt,height:ft},ht.small={top:0,left:0,width:H-Y,height:L-Z})}else ot.length>0&&0===nt.length?ht.big={top:0,left:0,width:H,height:L}:ht.small={top:Z,left:Y,width:H-Y,height:L-Z};ht.big&&(at=n({containerWidth:ht.big.width,containerHeight:ht.big.height,offsetLeft:ht.big.left,offsetTop:ht.big.top,fixedRatio:p,minRatio:x,maxRatio:b,alignItems:T,maxWidth:z,maxHeight:V,scaleLastRow:K,evenRows:U},ot)),ht.small&&(rt=n({containerWidth:ht.small.width,containerHeight:ht.small.height,offsetLeft:ht.small.left,offsetTop:ht.small.top,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:ht.big?S:O,maxWidth:ht.big?q:C,maxHeight:ht.big?F:E,scaleLastRow:G,evenRows:U},nt));var xt=[],yt=0,Rt=0;return e.forEach((function(t,e){it.indexOf(e)>-1?(xt[e]=at[yt],yt+=1):(xt[e]=rt[Rt],Rt+=1)})),{boxes:xt,areas:ht}}},function(t,e,i){"use strict"; /*! * opentok-layout-js (http://github.com/aullman/opentok-layout-js) * @@ -8,5 +8,5 @@ * @Author: Adam Ullman (http://github.com/aullman) * @Copyright (c) 2014 Adam Ullman * @License: Released under the MIT license (http://opensource.org/licenses/MIT) - * */e.__esModule=!0;var o=i(0),a=i(2);t.exports=function(t,e){var i=e&&e.window||("undefined"==typeof window?void 0:window);return t="string"==typeof t?i.document.querySelector(t):t,void 0===(i&&i.HTMLElement)||t instanceof i.HTMLElement||e?e||(e={}):e=t,{layout:a.default.bind(this,t,e),getLayout:o.default.bind(this,e)}}},function(t,e,i){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,i=1,o=arguments.length;i0?"".concat(u.offsetHeight,"px"):i(u,"height"))?parseInt(v,10):0)-n(t,"border-top")-n(t,"border-bottom"),e.containerWidth=function(t){var e,o=(e=t).offsetWidth>0?"".concat(e.offsetWidth,"px"):i(e,"width");return o?parseInt(o,10):0}(t)-n(t,"border-left")-n(t,"border-right");var m=Array.prototype.filter.call(t.querySelectorAll("#".concat(p,">*:not(.").concat(s,")")),(function(t){return"none"!==i(t,"display")})),b=m.map((function(t){return o(o({},function(t){if(t){if(t.videoHeight&&t.videoWidth)return{height:t.videoHeight,width:t.videoWidth};var e=t.querySelector("video");if(e&&e.videoHeight&&e.videoWidth)return{height:e.videoHeight,width:e.videoWidth}}return{height:480,width:640}}(t)),{big:t.classList.contains(f),fixedRatio:t.classList.contains(c)})}));(0,a.default)(e,b).boxes.forEach((function(t,o){var a=m[o];i(a,"position","absolute");var r=t.width-n(a,"margin-left")-n(a,"margin-right")-("border-box"!==i(a,"box-sizing")?n(a,"padding-left")+n(a,"padding-right")+n(a,"border-left")+n(a,"border-right"):0),d=t.height-n(a,"margin-top")-n(a,"margin-bottom")-("border-box"!==i(a,"box-sizing")?n(a,"padding-top")+n(a,"padding-bottom")+n(a,"border-top")+n(a,"border-bottom"):0);!function(t,e,o,a,n,r,h){var d=this,f={left:"".concat(e,"px"),top:"".concat(o,"px"),width:"".concat(a,"px"),height:"".concat(n,"px")},l=function(){var e=t.querySelector(".OT_root");if(e){var i=e.style.width;e.style.width="".concat(a,"px"),e.style.width=i||""}};if(r&&"undefined"!=typeof $){$(t).stop();var s="boolean"==typeof r?{duration:200,easing:"swing"}:r;$(t).animate(f,s.duration,s.easing,(function(){l(),s.complete&&s.complete.call(d),h&&h(t,{left:e,top:o,width:a,height:n})}))}else i(t,f),t.classList.contains("ot-layout")||t.classList.add("ot-layout"),h&&h(t,{left:e,top:o,width:a,height:n});l()}(a,t.left,t.top,r,d,h,e.onLayout)}))}}}])})); + * */var o=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var o,n=0,a=e.length;n0?"".concat(u.offsetHeight,"px"):i(u,"height"))?parseInt(v,10):0)-a(t,"border-top")-a(t,"border-bottom"),e.containerWidth=function(t){var e,o=(e=t).offsetWidth>0?"".concat(e.offsetWidth,"px"):i(e,"width");return o?parseInt(o,10):0}(t)-a(t,"border-left")-a(t,"border-right");var m=Array.prototype.filter.call(t.querySelectorAll("#".concat(p,">*:not(.").concat(s,")")),(function(t){return"none"!==i(t,"display")})),b=m.map((function(t){return o(o({},function(t){if(t){if(t.videoHeight&&t.videoWidth)return{height:t.videoHeight,width:t.videoWidth};var e=t.querySelector("video");if(e&&e.videoHeight&&e.videoWidth)return{height:e.videoHeight,width:e.videoWidth}}return{height:480,width:640}}(t)),{big:t.classList.contains(f),fixedRatio:t.classList.contains(c)})}));(0,n.default)(e,b).boxes.forEach((function(t,o){var n=m[o];i(n,"position","absolute");var r=t.width-a(n,"margin-left")-a(n,"margin-right")-("border-box"!==i(n,"box-sizing")?a(n,"padding-left")+a(n,"padding-right")+a(n,"border-left")+a(n,"border-right"):0),d=t.height-a(n,"margin-top")-a(n,"margin-bottom")-("border-box"!==i(n,"box-sizing")?a(n,"padding-top")+a(n,"padding-bottom")+a(n,"border-top")+a(n,"border-bottom"):0);!function(t,e,o,n,a,r,h){var d=this,f={left:"".concat(e,"px"),top:"".concat(o,"px"),width:"".concat(n,"px"),height:"".concat(a,"px")},l=function(){var e=t.querySelector(".OT_root");if(e){var i=e.style.width;e.style.width="".concat(n,"px"),e.style.width=i||""}};if(r&&"undefined"!=typeof $){$(t).stop();var s="boolean"==typeof r?{duration:200,easing:"swing"}:r;$(t).animate(f,s.duration,s.easing,(function(){l(),s.complete&&s.complete.call(d),h&&h(t,{left:e,top:o,width:n,height:a})}))}else i(t,f),t.classList.contains("ot-layout")||t.classList.add("ot-layout"),h&&h(t,{left:e,top:o,width:n,height:a});l()}(n,t.left,t.top,r,d,h,e.onLayout)}))}}}])})); //# sourceMappingURL=opentok-layout.min.js.map \ No newline at end of file diff --git a/opentok-layout.min.js.map b/opentok-layout.min.js.map index d7bc091..b0965d9 100644 --- a/opentok-layout.min.js.map +++ b/opentok-layout.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://initLayoutContainer/webpack/universalModuleDefinition","webpack://initLayoutContainer/webpack/bootstrap","webpack://initLayoutContainer/./src/getLayout.ts","webpack://initLayoutContainer/./src/index.ts","webpack://initLayoutContainer/./src/layout.ts"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getBestDimensions","minRatio","maxRatio","Width","Height","count","maxWidth","maxHeight","evenRows","maxArea","targetCols","targetRows","targetHeight","targetWidth","tWidth","tHeight","tRatio","cols","rows","Math","ceil","floor","area","min","undefined","ratio","getLayout","opts","elements","dimensions","fixedRatio","containerWidth","containerHeight","offsetLeft","offsetTop","alignItems","Infinity","scaleLastRow","ratios","map","element","height","width","length","row","x","y","boxes","push","totalRowHeight","remainingShortRows","remainingHeightDiff","extraHeight","rowMarginLeft","j","left","top","bigPercentage","minBigPercentage","bigFixedRatio","bigMaxRatio","bigMinRatio","bigFirst","bigAlignItems","smallAlignItems","smallMaxWidth","smallMaxHeight","bigMaxWidth","bigMaxHeight","bigScaleLastRow","availableRatio","bigOffsetTop","bigOffsetLeft","bigIndices","bigOnes","filter","idx","big","smallOnes","bigBoxes","smallBoxes","areas","bigWidth","bigHeight","showBigFirst","bigDimensions","max","forEach","box","small","bigBoxesIdx","smallBoxesIdx","indexOf","container","win","window","document","querySelector","HTMLElement","layout","css","el","propertyName","style","NaN","keys","currentValue","getComputedStyle","getPropertyValue","getCSSNumber","elem","prop","cssStr","parseInt","animate","bigClass","ignoreClass","fixedRatioClass","heightStr","id","getAttribute","random","toFixed","setAttribute","offsetHeight","widthStr","offsetWidth","getWidth","children","Array","querySelectorAll","child","videoHeight","videoWidth","video","getChildDims","classList","contains","actualWidth","actualHeight","w","h","onLayout","targetPosition","fixAspectRatio","sub","oldWidth","$","stop","duration","easing","complete","add","positionElement"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA6B,oBAAID,IAEjCD,EAA0B,oBAAIC,IARhC,CASmB,oBAATK,KAAuBA,KAAOC,MAAM,WAC9C,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUR,QAGnC,IAAIC,EAASK,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,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C,EAAmB,CACvCA,EAAErC,GAAMsC,OACR,IAAM,EAAgD,kBAAZlC,EAAwB,CAAEmC,SAAU,IAAKC,OAAQ,SAAYpC,EACvGiC,EAAErC,GAAMI,QAAQ6B,EAAgB,EAAaM,SAAU,EAAaC,QAClE,WACEN,IACI,EAAaO,UAAU,EAAaA,SAASpL,KAAK,GAClD2K,GACFA,EAAShC,EAAM,CACbvD,KAAMV,EACNW,IAAKV,EACLJ,MAAOkG,EACPnG,OAAQoG,YAKhBzC,EAAIU,EAAMiC,GACLjC,EAAK0B,UAAUC,SAAS,cAC3B3B,EAAK0B,UAAUgB,IAAI,aAEjBV,GACFA,EAAShC,EAAM,CACbvD,KAAMV,EACNW,IAAKV,EACLJ,MAAOkG,EACPnG,OAAQoG,IAIdG,IAwGAS,CAAgB3C,EAAMtB,EAAIjC,KAAMiC,EAAIhC,IAAKkF,EAAaC,EACpDzB,EAASvF,EAAKmH","file":"opentok-layout.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"initLayoutContainer\"] = factory();\n\telse\n\t\troot[\"initLayoutContainer\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/// \n\nimport { Element, Options, Box, GetLayoutRes } from 'opentok-layout-js';\n\nconst getBestDimensions = (minRatio: number, maxRatio: number, Width: number, Height: number, count: number, maxWidth: number, maxHeight: number, evenRows: boolean) => {\n let maxArea: number;\n let targetCols: number;\n let targetRows: number;\n let targetHeight: number;\n let targetWidth: number;\n let tWidth: number;\n let tHeight: number;\n let tRatio: number;\n\n // Iterate through every possible combination of rows and columns\n // and see which one has the least amount of whitespace\n for (let i = 1; i <= count; i += 1) {\n const cols = i;\n const rows = Math.ceil(count / cols);\n\n // Try taking up the whole height and width\n tHeight = Math.floor(Height / rows);\n tWidth = Math.floor(Width / cols);\n\n tRatio = tHeight / tWidth;\n if (tRatio > maxRatio) {\n // We went over decrease the height\n tRatio = maxRatio;\n tHeight = tWidth * tRatio;\n } else if (tRatio < minRatio) {\n // We went under decrease the width\n tRatio = minRatio;\n tWidth = tHeight / tRatio;\n }\n\n tWidth = Math.min(maxWidth, tWidth);\n tHeight = Math.min(maxHeight, tHeight);\n\n const area = (tWidth * tHeight) * count;\n\n // If this width and height takes up the most space then we're going with that\n if (maxArea === undefined || (area >= maxArea)) {\n if (evenRows && area === maxArea && ((cols * rows) % count) > ((targetRows * targetCols) % count)) {\n // We have the same area but there are more left over spots in the last row\n // Let's keep the previous one\n continue;\n }\n maxArea = area;\n targetHeight = tHeight;\n targetWidth = tWidth;\n targetCols = cols;\n targetRows = rows;\n }\n }\n return {\n maxArea,\n targetCols,\n targetRows,\n targetHeight,\n targetWidth,\n ratio: targetHeight / targetWidth,\n };\n};\n\ntype Offsets = {\n offsetLeft: number;\n offsetTop: number;\n}\n\ntype Row = {\n ratios: number[];\n elements: Element[];\n width: number;\n height: number;\n}\n\ntype Areas = { small?: Box, big?: Box }\n\nconst getLayout = (opts: Options & Offsets, elements: Element[]): Box[] => {\n const {\n maxRatio,\n minRatio,\n fixedRatio,\n containerWidth,\n containerHeight,\n offsetLeft = 0,\n offsetTop = 0,\n alignItems = 'center',\n maxWidth = Infinity,\n maxHeight = Infinity,\n scaleLastRow = true,\n evenRows = true,\n } = opts;\n const ratios = elements.map(element => element.height / element.width);\n const count = ratios.length;\n\n\n let dimensions: ReturnType;\n\n if (!fixedRatio) {\n dimensions = getBestDimensions(minRatio, maxRatio, containerWidth, containerHeight, count,\n maxWidth, maxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = ratios.length > 0 ? ratios[0] : null;\n dimensions = getBestDimensions(ratio, ratio, containerWidth, containerHeight, count,\n maxWidth, maxHeight, evenRows);\n }\n\n // Loop through each stream in the container and place it inside\n let x = 0;\n let y = 0;\n const rows: Row[] = [];\n let row: Row;\n const boxes: Box[] = [];\n // Iterate through the children and create an array with a new item for each row\n // and calculate the width of each row so that we know if we go over the size and need\n // to adjust\n for (let i = 0; i < ratios.length; i += 1) {\n if (i % dimensions.targetCols === 0) {\n // This is a new row\n row = {\n ratios: [],\n elements: [],\n width: 0,\n height: 0,\n };\n rows.push(row);\n }\n const ratio = ratios[i];\n const element = elements[i];\n row.elements.push(element);\n row.ratios.push(ratio);\n let targetWidth = dimensions.targetWidth;\n const targetHeight = dimensions.targetHeight;\n // If we're using a fixedRatio then we need to set the correct ratio for this element\n if (fixedRatio || element.fixedRatio) {\n targetWidth = targetHeight / ratio;\n }\n row.width += targetWidth;\n row.height = targetHeight;\n }\n // Calculate total row height adjusting if we go too wide\n let totalRowHeight = 0;\n let remainingShortRows = 0;\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n if (row.width > containerWidth) {\n // Went over on the width, need to adjust the height proportionally\n row.height = Math.floor(row.height * (containerWidth / row.width));\n row.width = containerWidth;\n } else if (row.width < containerWidth && row.height < maxHeight) {\n remainingShortRows += 1;\n }\n totalRowHeight += row.height;\n }\n if (scaleLastRow && totalRowHeight < containerHeight && remainingShortRows > 0) {\n // We can grow some of the rows, we're not taking up the whole height\n let remainingHeightDiff = containerHeight - totalRowHeight;\n totalRowHeight = 0;\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n if (row.width < containerWidth) {\n // Evenly distribute the extra height between the short rows\n let extraHeight = remainingHeightDiff / remainingShortRows;\n if ((extraHeight / row.height) > ((containerWidth - row.width) / row.width)) {\n // We can't go that big or we'll go too wide\n extraHeight = Math.floor(((containerWidth - row.width) / row.width) * row.height);\n }\n row.width += Math.floor((extraHeight / row.height) * row.width);\n row.height += extraHeight;\n remainingHeightDiff -= extraHeight;\n remainingShortRows -= 1;\n }\n totalRowHeight += row.height;\n }\n }\n switch (alignItems) {\n case 'start':\n y = 0;\n break;\n case 'end':\n y = containerHeight - totalRowHeight;\n break;\n case 'center':\n default:\n y = ((containerHeight - (totalRowHeight)) / 2);\n break;\n }\n // Iterate through each row and place each child\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n let rowMarginLeft;\n switch (alignItems) {\n case 'start':\n rowMarginLeft = 0;\n break;\n case 'end':\n rowMarginLeft = containerWidth - row.width;\n break;\n case 'center':\n default:\n rowMarginLeft = ((containerWidth - row.width) / 2);\n break;\n }\n x = rowMarginLeft;\n let targetHeight;\n for (let j = 0; j < row.ratios.length; j += 1) {\n const ratio = row.ratios[j];\n const element = row.elements[j];\n\n let targetWidth = dimensions.targetWidth;\n targetHeight = row.height;\n // If we're using a fixedRatio then we need to set the correct ratio for this element\n if (fixedRatio || element.fixedRatio) {\n targetWidth = Math.floor(targetHeight / ratio);\n } else if ((targetHeight / targetWidth)\n !== (dimensions.targetHeight / dimensions.targetWidth)) {\n // We grew this row, we need to adjust the width to account for the increase in height\n targetWidth = Math.floor((dimensions.targetWidth / dimensions.targetHeight) * targetHeight);\n }\n\n boxes.push({\n left: x + offsetLeft,\n top: y + offsetTop,\n width: targetWidth,\n height: targetHeight,\n });\n x += targetWidth;\n }\n y += targetHeight;\n }\n return boxes;\n};\n\nconst getVideoRatio = (element: Element) => element.height / element.width;\n\nexport default (opts: Options, elements: Element[]): GetLayoutRes => {\n const {\n maxRatio = 3 / 2,\n minRatio = 9 / 16,\n fixedRatio = false,\n bigPercentage = 0.8,\n minBigPercentage = 0,\n bigFixedRatio = false,\n bigMaxRatio = 3 / 2,\n bigMinRatio = 9 / 16,\n bigFirst = true,\n containerWidth = 640,\n containerHeight = 480,\n alignItems = 'center',\n bigAlignItems = 'center',\n smallAlignItems = 'center',\n maxWidth = Infinity,\n maxHeight = Infinity,\n smallMaxWidth = Infinity,\n smallMaxHeight = Infinity,\n bigMaxWidth = Infinity,\n bigMaxHeight = Infinity,\n scaleLastRow = true,\n bigScaleLastRow = true,\n evenRows = true,\n } = opts;\n\n const availableRatio = containerHeight / containerWidth;\n let offsetLeft = 0;\n let offsetTop = 0;\n let bigOffsetTop = 0;\n let bigOffsetLeft = 0;\n const bigIndices: number[] = [];\n const bigOnes = elements.filter((element, idx) => {\n if (element.big) {\n bigIndices.push(idx);\n return true;\n }\n return false;\n });\n const smallOnes = elements.filter(element => !element.big);\n let bigBoxes: Box[] = [];\n let smallBoxes: Box[] = [];\n const areas: Areas = {};\n if (bigOnes.length > 0 && smallOnes.length > 0) {\n let bigWidth: number;\n let bigHeight: number;\n let showBigFirst = bigFirst === true;\n\n if (availableRatio > getVideoRatio(bigOnes[0])) {\n // We are tall, going to take up the whole width and arrange small\n // guys at the bottom\n bigWidth = containerWidth;\n bigHeight = Math.floor(containerHeight * bigPercentage);\n if (minBigPercentage > 0) {\n // Find the best size for the big area\n let bigDimensions: ReturnType;\n if (!bigFixedRatio) {\n bigDimensions = getBestDimensions(bigMinRatio, bigMaxRatio, bigWidth,\n bigHeight, bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = bigOnes[0].height / bigOnes[0].width;\n bigDimensions = getBestDimensions(ratio, ratio, bigWidth, bigHeight,\n bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n }\n bigHeight = Math.max(containerHeight * minBigPercentage,\n Math.min(bigHeight, bigDimensions.targetHeight * bigDimensions.targetRows));\n // Don't awkwardly scale the small area bigger than we need to and end up with floating\n // videos in the middle\n const smallBoxes = getLayout({\n containerWidth: containerWidth,\n containerHeight: containerHeight - bigHeight,\n offsetLeft: 0,\n offsetTop: 0,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: smallAlignItems,\n maxWidth: smallMaxWidth,\n maxHeight: smallMaxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n let smallHeight = 0\n let currentTop = undefined\n smallBoxes.forEach(box => {\n if (currentTop !== box.top) {\n currentTop = box.top\n smallHeight += box.height\n }\n })\n bigHeight = Math.max(bigHeight, containerHeight - smallHeight);\n }\n offsetTop = bigHeight;\n bigOffsetTop = containerHeight - offsetTop;\n if (bigFirst === 'column') {\n showBigFirst = false;\n } else if (bigFirst === 'row') {\n showBigFirst = true;\n }\n } else {\n // We are wide, going to take up the whole height and arrange the small\n // guys on the right\n bigHeight = containerHeight;\n bigWidth = Math.floor(containerWidth * bigPercentage);\n if (minBigPercentage > 0) {\n // Find the best size for the big area\n let bigDimensions: ReturnType;\n if (!bigFixedRatio) {\n bigDimensions = getBestDimensions(bigMinRatio, bigMaxRatio, bigWidth,\n bigHeight, bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = bigOnes[0].height / bigOnes[0].width;\n bigDimensions = getBestDimensions(ratio, ratio, bigWidth, bigHeight,\n bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n }\n bigWidth = Math.max(containerWidth * minBigPercentage,\n Math.min(bigWidth, bigDimensions.targetWidth * bigDimensions.targetCols));\n // Don't awkwardly scale the small area bigger than we need to and end up with floating\n // videos in the middle\n const smallBoxes = getLayout({\n containerWidth: containerWidth - bigWidth,\n containerHeight: containerHeight,\n offsetLeft: 0,\n offsetTop: 0,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: smallAlignItems,\n maxWidth: smallMaxWidth,\n maxHeight: smallMaxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n let smallWidth = 0\n let currentWidth = 0\n let top = 0\n smallBoxes.forEach(box => {\n if (box.top !== top) {\n currentWidth = 0\n top = box.top\n }\n currentWidth += box.width\n smallWidth = Math.max(smallWidth, currentWidth)\n })\n bigWidth = Math.max(bigWidth, containerWidth - smallWidth);\n }\n offsetLeft = bigWidth;\n bigOffsetLeft = containerWidth - offsetLeft;\n if (bigFirst === 'column') {\n showBigFirst = true;\n } else if (bigFirst === 'row') {\n showBigFirst = false;\n }\n }\n if (showBigFirst) {\n areas.big = {\n top: 0,\n left: 0,\n width: bigWidth,\n height: bigHeight,\n };\n areas.small = {\n top: offsetTop,\n left: offsetLeft,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n } else {\n areas.big = {\n left: bigOffsetLeft,\n top: bigOffsetTop,\n width: bigWidth,\n height: bigHeight,\n };\n areas.small = {\n top: 0,\n left: 0,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n }\n } else if (bigOnes.length > 0 && smallOnes.length === 0) {\n // We only have one bigOne just center it\n areas.big = {\n top: 0,\n left: 0,\n width: containerWidth,\n height: containerHeight,\n };\n } else {\n areas.small = {\n top: offsetTop,\n left: offsetLeft,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n }\n\n if (areas.big) {\n bigBoxes = getLayout({\n containerWidth: areas.big.width,\n containerHeight: areas.big.height,\n offsetLeft: areas.big.left,\n offsetTop: areas.big.top,\n fixedRatio: bigFixedRatio,\n minRatio: bigMinRatio,\n maxRatio: bigMaxRatio,\n alignItems: bigAlignItems,\n maxWidth: bigMaxWidth,\n maxHeight: bigMaxHeight,\n scaleLastRow: bigScaleLastRow,\n evenRows,\n }, bigOnes);\n }\n if (areas.small) {\n smallBoxes = getLayout({\n containerWidth: areas.small.width,\n containerHeight: areas.small.height,\n offsetLeft: areas.small.left,\n offsetTop: areas.small.top,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: areas.big ? smallAlignItems : alignItems,\n maxWidth: areas.big ? smallMaxWidth : maxWidth,\n maxHeight: areas.big ? smallMaxHeight : maxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n }\n\n const boxes: Box[] = [];\n let bigBoxesIdx = 0;\n let smallBoxesIdx = 0;\n // Rebuild the array in the right order based on where the bigIndices should be\n elements.forEach((element, idx) => {\n if (bigIndices.indexOf(idx) > -1) {\n boxes[idx] = bigBoxes[bigBoxesIdx];\n bigBoxesIdx += 1;\n } else {\n boxes[idx] = smallBoxes[smallBoxesIdx];\n smallBoxesIdx += 1;\n }\n });\n return { boxes, areas };\n};\n","/// \n/*!\n * opentok-layout-js (http://github.com/aullman/opentok-layout-js)\n *\n * Automatic layout of video elements (publisher and subscriber) minimising\n * white-space for the OpenTok on WebRTC API.\n *\n * @Author: Adam Ullman (http://github.com/aullman)\n * @Copyright (c) 2014 Adam Ullman\n * @License: Released under the MIT license (http://opensource.org/licenses/MIT)\n * */\n\n// in CommonJS context, this should be a `require()`d dependency.\n// in browser globals context, ...? (when using bower, there are dependencies that it has handled\n// for you, so these might be safe to assume)\n\nimport getLayout from './getLayout'\nimport layout from './layout'\nimport type { Options, LayoutContainer } from 'opentok-layout-js'\n\ndeclare global {\n interface Window {\n HTMLElement: typeof HTMLElement;\n }\n}\n\nmodule.exports = function initLayoutContainer(container: HTMLElement | Options, opts: Options): LayoutContainer {\n const win = (opts && opts.window) || (typeof window === 'undefined' ? undefined : window);\n container = typeof container === 'string' ? win.document.querySelector(container) : container;\n if (!(typeof (win && win.HTMLElement) === 'undefined' || container instanceof win.HTMLElement) && !opts) {\n // container is actually the options\n opts = container as Options;\n } else if (!opts) {\n opts = {};\n }\n\n return {\n layout: layout.bind(this, container, opts),\n getLayout: getLayout.bind(this, opts),\n };\n};\n","/// \n\nimport { Options, Element, OnLayout, Animate, AnimateProps } from 'opentok-layout-js';\nimport getLayout from './getLayout';\n\nexport default (container: HTMLElement, opts: Options) => {\n function css(el: HTMLElement, propertyName: Record): typeof NaN\n function css(el: HTMLElement, propertyName: string, value: string): typeof NaN\n function css(el: HTMLElement, propertyName: string): string\n function css(el: HTMLElement, propertyName: string | Record, value?: string) {\n if (typeof propertyName === 'string' && value) {\n // We are setting one css property\n el.style[propertyName] = value;\n return NaN;\n }\n if (typeof propertyName === 'object') {\n // We are setting several CSS properties at once\n Object.keys(propertyName).forEach((key) => {\n css(el, key, propertyName[key]);\n });\n return NaN;\n }\n // We are getting the css property\n const computedStyle = ((opts && opts.window) || window).getComputedStyle(el);\n let currentValue = computedStyle.getPropertyValue(propertyName);\n\n if (currentValue === '') {\n currentValue = el.style[propertyName];\n }\n\n return currentValue;\n }\n\n const filterDisplayNone = element => css(element, 'display') !== 'none';\n\n function height(el) {\n if (el.offsetHeight > 0) {\n return `${el.offsetHeight}px`;\n }\n return css(el, 'height');\n }\n\n function width(el) {\n if (el.offsetWidth > 0) {\n return `${el.offsetWidth}px`;\n }\n return css(el, 'width');\n }\n\n const positionElement = function positionElement(elem: HTMLElement, x: number, y: number, w: number, h: number, animate: Animate, onLayout: OnLayout) {\n const targetPosition = {\n left: `${x}px`,\n top: `${y}px`,\n width: `${w}px`,\n height: `${h}px`,\n };\n\n const fixAspectRatio = function fixAspectRatio() {\n const sub = elem.querySelector('.OT_root') as HTMLElement;\n if (sub) {\n // If this is the parent of a subscriber or publisher then we need\n // to force the mutation observer on the publisher or subscriber to\n // trigger to get it to fix it's layout\n const oldWidth = sub.style.width;\n sub.style.width = `${w}px`;\n // sub.style.height = height + 'px';\n sub.style.width = oldWidth || '';\n }\n };\n\n if (animate && typeof $ !== 'undefined') {\n $(elem).stop();\n const animateProps: AnimateProps = typeof animate === 'boolean' ? { duration: 200, easing: 'swing' } : animate;\n $(elem).animate(targetPosition, animateProps.duration, animateProps.easing,\n () => {\n fixAspectRatio();\n if (animateProps.complete) animateProps.complete.call(this);\n if (onLayout) {\n onLayout(elem, {\n left: x,\n top: y,\n width: w,\n height: h,\n });\n }\n });\n } else {\n css(elem, targetPosition);\n if (!elem.classList.contains('ot-layout')) {\n elem.classList.add('ot-layout');\n }\n if (onLayout) {\n onLayout(elem, {\n left: x,\n top: y,\n width: w,\n height: h,\n });\n }\n }\n fixAspectRatio();\n };\n\n const getChildDims = function getChildDims(child: HTMLVideoElement | HTMLElement): Omit {\n if (child) {\n if ((child as HTMLVideoElement).videoHeight && (child as HTMLVideoElement).videoWidth) {\n return {\n height: (child as HTMLVideoElement).videoHeight,\n width: (child as HTMLVideoElement).videoWidth,\n };\n }\n const video = child.querySelector('video');\n if (video && video.videoHeight && video.videoWidth) {\n return {\n height: video.videoHeight,\n width: video.videoWidth,\n };\n }\n }\n return {\n height: 480,\n width: 640,\n };\n };\n\n const getCSSNumber = function getCSSNumber(elem: HTMLElement, prop: string) {\n const cssStr = css(elem, prop);\n return cssStr ? parseInt(cssStr, 10) : 0;\n };\n\n // Really cheap UUID function\n const cheapUUID = function cheapUUID() {\n return (Math.random() * 100000000).toFixed(0);\n };\n\n const getHeight = function getHeight(elem) {\n const heightStr = height(elem);\n return heightStr ? parseInt(heightStr, 10) : 0;\n };\n\n const getWidth = function getWidth(elem) {\n const widthStr = width(elem);\n return widthStr ? parseInt(widthStr, 10) : 0;\n };\n\n const {\n animate = false,\n bigClass = 'OT_big',\n ignoreClass = 'OT_ignore',\n fixedRatioClass = 'OT_fixedRatio',\n } = opts;\n\n if (css(container, 'display') === 'none') {\n return;\n }\n let id = container.getAttribute('id');\n if (!id) {\n id = `OT_${cheapUUID()}`;\n container.setAttribute('id', id);\n }\n\n opts.containerHeight = getHeight(container)\n - getCSSNumber(container, 'border-top')\n - getCSSNumber(container, 'border-bottom');\n opts.containerWidth = getWidth(container)\n - getCSSNumber(container, 'border-left')\n - getCSSNumber(container, 'border-right');\n\n const children: HTMLElement[] = Array.prototype.filter.call(\n container.querySelectorAll(`#${id}>*:not(.${ignoreClass})`),\n filterDisplayNone\n );\n const elements: Element[] = children.map((element) => {\n return {\n ...getChildDims(element),\n big: element.classList.contains(bigClass),\n fixedRatio: element.classList.contains(fixedRatioClass),\n };\n });\n\n const layout = getLayout(opts, elements);\n layout.boxes.forEach((box, idx) => {\n const elem = children[idx];\n css(elem, 'position', 'absolute');\n const actualWidth = box.width\n - getCSSNumber(elem, 'margin-left')\n - getCSSNumber(elem, 'margin-right')\n - (css(elem, 'box-sizing') !== 'border-box'\n ? (getCSSNumber(elem, 'padding-left')\n + getCSSNumber(elem, 'padding-right')\n + getCSSNumber(elem, 'border-left')\n + getCSSNumber(elem, 'border-right'))\n : 0);\n\n const actualHeight = box.height\n - getCSSNumber(elem, 'margin-top')\n - getCSSNumber(elem, 'margin-bottom')\n - (css(elem, 'box-sizing') !== 'border-box'\n ? (getCSSNumber(elem, 'padding-top')\n + getCSSNumber(elem, 'padding-bottom')\n + getCSSNumber(elem, 'border-top')\n + getCSSNumber(elem, 'border-bottom'))\n : 0);\n\n positionElement(elem, box.left, box.top, actualWidth, actualHeight,\n animate, opts.onLayout);\n });\n};\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://initLayoutContainer/webpack/universalModuleDefinition","webpack://initLayoutContainer/webpack/bootstrap","webpack://initLayoutContainer/./src/getLayout.ts","webpack://initLayoutContainer/./src/index.ts","webpack://initLayoutContainer/./src/layout.ts"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getBestDimensions","minRatio","maxRatio","Width","Height","count","maxWidth","maxHeight","evenRows","maxArea","targetCols","targetRows","targetHeight","targetWidth","tWidth","tHeight","tRatio","cols","rows","Math","ceil","floor","area","min","undefined","ratio","getLayout","opts","elements","dimensions","fixedRatio","containerWidth","containerHeight","offsetLeft","offsetTop","alignItems","Infinity","scaleLastRow","ratios","map","element","height","width","length","row","x","y","boxes","push","totalRowHeight","remainingShortRows","remainingHeightDiff","extraHeight","rowMarginLeft","j","left","top","bigPercentage","minBigPercentage","bigFixedRatio","bigMaxRatio","bigMinRatio","bigFirst","bigAlignItems","smallAlignItems","smallMaxWidth","smallMaxHeight","bigMaxWidth","bigMaxHeight","bigScaleLastRow","availableRatio","bigOffsetTop","bigOffsetLeft","bigIndices","bigOnes","filter","idx","big","smallOnes","bigBoxes","smallBoxes","areas","bigWidth","bigHeight","showBigFirst","bigDimensions","max","forEach","box","small","bigBoxesIdx","smallBoxesIdx","indexOf","container","options","win","window","document","querySelector","HTMLElement","layout","apply","console","log","args","setOptions","newOptions","css","el","propertyName","style","NaN","keys","currentValue","getComputedStyle","getPropertyValue","getCSSNumber","elem","prop","cssStr","parseInt","animate","bigClass","ignoreClass","fixedRatioClass","heightStr","id","getAttribute","random","toFixed","setAttribute","offsetHeight","widthStr","offsetWidth","getWidth","children","Array","querySelectorAll","child","videoHeight","videoWidth","video","getChildDims","classList","contains","actualWidth","actualHeight","w","h","onLayout","targetPosition","fixAspectRatio","sub","oldWidth","$","stop","duration","easing","complete","add","positionElement"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA6B,oBAAID,IAEjCD,EAA0B,oBAAIC,IARhC,CASmB,oBAATK,KAAuBA,KAAOC,MAAM,WAC9C,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUR,QAGnC,IAAIC,EAASK,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHV,QAAS,IAUV,OANAW,EAAQH,GAAUI,KAAKX,EAAOD,QAASC,EAAQA,EAAOD,QAASO,GAG/DN,EAAOS,GAAI,EAGJT,EAAOD,QA0Df,OArDAO,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASf,EAASgB,EAAMC,GAC3CV,EAAoBW,EAAElB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AMI,QAAQ6B,EAAgB,EAAaM,SAAU,EAAaC,QAClE,WACEN,IACI,EAAaO,UAAU,EAAaA,SAAS3L,KAAK,GAClDkL,GACFA,EAAShC,EAAM,CACb9D,KAAMV,EACNW,IAAKV,EACLJ,MAAOyG,EACP1G,OAAQ2G,YAKhBzC,EAAIU,EAAMiC,GACLjC,EAAK0B,UAAUC,SAAS,cAC3B3B,EAAK0B,UAAUgB,IAAI,aAEjBV,GACFA,EAAShC,EAAM,CACb9D,KAAMV,EACNW,IAAKV,EACLJ,MAAOyG,EACP1G,OAAQ2G,IAIdG,IAwGAS,CAAgB3C,EAAM7B,EAAIjC,KAAMiC,EAAIhC,IAAKyF,EAAaC,EACpDzB,EAAS9F,EAAK0H","file":"opentok-layout.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"initLayoutContainer\"] = factory();\n\telse\n\t\troot[\"initLayoutContainer\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/// \n\nimport { Element, Options, Box, GetLayoutRes } from 'opentok-layout-js';\n\nconst getBestDimensions = (minRatio: number, maxRatio: number, Width: number, Height: number, count: number, maxWidth: number, maxHeight: number, evenRows: boolean) => {\n let maxArea: number;\n let targetCols: number;\n let targetRows: number;\n let targetHeight: number;\n let targetWidth: number;\n let tWidth: number;\n let tHeight: number;\n let tRatio: number;\n\n // Iterate through every possible combination of rows and columns\n // and see which one has the least amount of whitespace\n for (let i = 1; i <= count; i += 1) {\n const cols = i;\n const rows = Math.ceil(count / cols);\n\n // Try taking up the whole height and width\n tHeight = Math.floor(Height / rows);\n tWidth = Math.floor(Width / cols);\n\n tRatio = tHeight / tWidth;\n if (tRatio > maxRatio) {\n // We went over decrease the height\n tRatio = maxRatio;\n tHeight = tWidth * tRatio;\n } else if (tRatio < minRatio) {\n // We went under decrease the width\n tRatio = minRatio;\n tWidth = tHeight / tRatio;\n }\n\n tWidth = Math.min(maxWidth, tWidth);\n tHeight = Math.min(maxHeight, tHeight);\n\n const area = (tWidth * tHeight) * count;\n\n // If this width and height takes up the most space then we're going with that\n if (maxArea === undefined || (area >= maxArea)) {\n if (evenRows && area === maxArea && ((cols * rows) % count) > ((targetRows * targetCols) % count)) {\n // We have the same area but there are more left over spots in the last row\n // Let's keep the previous one\n continue;\n }\n maxArea = area;\n targetHeight = tHeight;\n targetWidth = tWidth;\n targetCols = cols;\n targetRows = rows;\n }\n }\n return {\n maxArea,\n targetCols,\n targetRows,\n targetHeight,\n targetWidth,\n ratio: targetHeight / targetWidth,\n };\n};\n\ntype Offsets = {\n offsetLeft: number;\n offsetTop: number;\n}\n\ntype Row = {\n ratios: number[];\n elements: Element[];\n width: number;\n height: number;\n}\n\ntype Areas = { small?: Box, big?: Box }\n\nconst getLayout = (opts: Options & Offsets, elements: Element[]): Box[] => {\n const {\n maxRatio,\n minRatio,\n fixedRatio,\n containerWidth,\n containerHeight,\n offsetLeft = 0,\n offsetTop = 0,\n alignItems = 'center',\n maxWidth = Infinity,\n maxHeight = Infinity,\n scaleLastRow = true,\n evenRows = true,\n } = opts;\n const ratios = elements.map(element => element.height / element.width);\n const count = ratios.length;\n\n\n let dimensions: ReturnType;\n\n if (!fixedRatio) {\n dimensions = getBestDimensions(minRatio, maxRatio, containerWidth, containerHeight, count,\n maxWidth, maxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = ratios.length > 0 ? ratios[0] : null;\n dimensions = getBestDimensions(ratio, ratio, containerWidth, containerHeight, count,\n maxWidth, maxHeight, evenRows);\n }\n\n // Loop through each stream in the container and place it inside\n let x = 0;\n let y = 0;\n const rows: Row[] = [];\n let row: Row;\n const boxes: Box[] = [];\n // Iterate through the children and create an array with a new item for each row\n // and calculate the width of each row so that we know if we go over the size and need\n // to adjust\n for (let i = 0; i < ratios.length; i += 1) {\n if (i % dimensions.targetCols === 0) {\n // This is a new row\n row = {\n ratios: [],\n elements: [],\n width: 0,\n height: 0,\n };\n rows.push(row);\n }\n const ratio = ratios[i];\n const element = elements[i];\n row.elements.push(element);\n row.ratios.push(ratio);\n let targetWidth = dimensions.targetWidth;\n const targetHeight = dimensions.targetHeight;\n // If we're using a fixedRatio then we need to set the correct ratio for this element\n if (fixedRatio || element.fixedRatio) {\n targetWidth = targetHeight / ratio;\n }\n row.width += targetWidth;\n row.height = targetHeight;\n }\n // Calculate total row height adjusting if we go too wide\n let totalRowHeight = 0;\n let remainingShortRows = 0;\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n if (row.width > containerWidth) {\n // Went over on the width, need to adjust the height proportionally\n row.height = Math.floor(row.height * (containerWidth / row.width));\n row.width = containerWidth;\n } else if (row.width < containerWidth && row.height < maxHeight) {\n remainingShortRows += 1;\n }\n totalRowHeight += row.height;\n }\n if (scaleLastRow && totalRowHeight < containerHeight && remainingShortRows > 0) {\n // We can grow some of the rows, we're not taking up the whole height\n let remainingHeightDiff = containerHeight - totalRowHeight;\n totalRowHeight = 0;\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n if (row.width < containerWidth) {\n // Evenly distribute the extra height between the short rows\n let extraHeight = remainingHeightDiff / remainingShortRows;\n if ((extraHeight / row.height) > ((containerWidth - row.width) / row.width)) {\n // We can't go that big or we'll go too wide\n extraHeight = Math.floor(((containerWidth - row.width) / row.width) * row.height);\n }\n row.width += Math.floor((extraHeight / row.height) * row.width);\n row.height += extraHeight;\n remainingHeightDiff -= extraHeight;\n remainingShortRows -= 1;\n }\n totalRowHeight += row.height;\n }\n }\n switch (alignItems) {\n case 'start':\n y = 0;\n break;\n case 'end':\n y = containerHeight - totalRowHeight;\n break;\n case 'center':\n default:\n y = ((containerHeight - (totalRowHeight)) / 2);\n break;\n }\n // Iterate through each row and place each child\n for (let i = 0; i < rows.length; i += 1) {\n row = rows[i];\n let rowMarginLeft;\n switch (alignItems) {\n case 'start':\n rowMarginLeft = 0;\n break;\n case 'end':\n rowMarginLeft = containerWidth - row.width;\n break;\n case 'center':\n default:\n rowMarginLeft = ((containerWidth - row.width) / 2);\n break;\n }\n x = rowMarginLeft;\n let targetHeight;\n for (let j = 0; j < row.ratios.length; j += 1) {\n const ratio = row.ratios[j];\n const element = row.elements[j];\n\n let targetWidth = dimensions.targetWidth;\n targetHeight = row.height;\n // If we're using a fixedRatio then we need to set the correct ratio for this element\n if (fixedRatio || element.fixedRatio) {\n targetWidth = Math.floor(targetHeight / ratio);\n } else if ((targetHeight / targetWidth)\n !== (dimensions.targetHeight / dimensions.targetWidth)) {\n // We grew this row, we need to adjust the width to account for the increase in height\n targetWidth = Math.floor((dimensions.targetWidth / dimensions.targetHeight) * targetHeight);\n }\n\n boxes.push({\n left: x + offsetLeft,\n top: y + offsetTop,\n width: targetWidth,\n height: targetHeight,\n });\n x += targetWidth;\n }\n y += targetHeight;\n }\n return boxes;\n};\n\nconst getVideoRatio = (element: Element) => element.height / element.width;\n\nexport default (opts: Options, elements: Element[]): GetLayoutRes => {\n const {\n maxRatio = 3 / 2,\n minRatio = 9 / 16,\n fixedRatio = false,\n bigPercentage = 0.8,\n minBigPercentage = 0,\n bigFixedRatio = false,\n bigMaxRatio = 3 / 2,\n bigMinRatio = 9 / 16,\n bigFirst = true,\n containerWidth = 640,\n containerHeight = 480,\n alignItems = 'center',\n bigAlignItems = 'center',\n smallAlignItems = 'center',\n maxWidth = Infinity,\n maxHeight = Infinity,\n smallMaxWidth = Infinity,\n smallMaxHeight = Infinity,\n bigMaxWidth = Infinity,\n bigMaxHeight = Infinity,\n scaleLastRow = true,\n bigScaleLastRow = true,\n evenRows = true,\n } = opts;\n\n const availableRatio = containerHeight / containerWidth;\n let offsetLeft = 0;\n let offsetTop = 0;\n let bigOffsetTop = 0;\n let bigOffsetLeft = 0;\n const bigIndices: number[] = [];\n const bigOnes = elements.filter((element, idx) => {\n if (element.big) {\n bigIndices.push(idx);\n return true;\n }\n return false;\n });\n const smallOnes = elements.filter(element => !element.big);\n let bigBoxes: Box[] = [];\n let smallBoxes: Box[] = [];\n const areas: Areas = {};\n if (bigOnes.length > 0 && smallOnes.length > 0) {\n let bigWidth: number;\n let bigHeight: number;\n let showBigFirst = bigFirst === true;\n\n if (availableRatio > getVideoRatio(bigOnes[0])) {\n // We are tall, going to take up the whole width and arrange small\n // guys at the bottom\n bigWidth = containerWidth;\n bigHeight = Math.floor(containerHeight * bigPercentage);\n if (minBigPercentage > 0) {\n // Find the best size for the big area\n let bigDimensions: ReturnType;\n if (!bigFixedRatio) {\n bigDimensions = getBestDimensions(bigMinRatio, bigMaxRatio, bigWidth,\n bigHeight, bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = bigOnes[0].height / bigOnes[0].width;\n bigDimensions = getBestDimensions(ratio, ratio, bigWidth, bigHeight,\n bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n }\n bigHeight = Math.max(containerHeight * minBigPercentage,\n Math.min(bigHeight, bigDimensions.targetHeight * bigDimensions.targetRows));\n // Don't awkwardly scale the small area bigger than we need to and end up with floating\n // videos in the middle\n const smallBoxes = getLayout({\n containerWidth: containerWidth,\n containerHeight: containerHeight - bigHeight,\n offsetLeft: 0,\n offsetTop: 0,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: smallAlignItems,\n maxWidth: smallMaxWidth,\n maxHeight: smallMaxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n let smallHeight = 0\n let currentTop = undefined\n smallBoxes.forEach(box => {\n if (currentTop !== box.top) {\n currentTop = box.top\n smallHeight += box.height\n }\n })\n bigHeight = Math.max(bigHeight, containerHeight - smallHeight);\n }\n offsetTop = bigHeight;\n bigOffsetTop = containerHeight - offsetTop;\n if (bigFirst === 'column') {\n showBigFirst = false;\n } else if (bigFirst === 'row') {\n showBigFirst = true;\n }\n } else {\n // We are wide, going to take up the whole height and arrange the small\n // guys on the right\n bigHeight = containerHeight;\n bigWidth = Math.floor(containerWidth * bigPercentage);\n if (minBigPercentage > 0) {\n // Find the best size for the big area\n let bigDimensions: ReturnType;\n if (!bigFixedRatio) {\n bigDimensions = getBestDimensions(bigMinRatio, bigMaxRatio, bigWidth,\n bigHeight, bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n } else {\n // Use the ratio of the first video element we find to approximate\n const ratio = bigOnes[0].height / bigOnes[0].width;\n bigDimensions = getBestDimensions(ratio, ratio, bigWidth, bigHeight,\n bigOnes.length, bigMaxWidth, bigMaxHeight, evenRows);\n }\n bigWidth = Math.max(containerWidth * minBigPercentage,\n Math.min(bigWidth, bigDimensions.targetWidth * bigDimensions.targetCols));\n // Don't awkwardly scale the small area bigger than we need to and end up with floating\n // videos in the middle\n const smallBoxes = getLayout({\n containerWidth: containerWidth - bigWidth,\n containerHeight: containerHeight,\n offsetLeft: 0,\n offsetTop: 0,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: smallAlignItems,\n maxWidth: smallMaxWidth,\n maxHeight: smallMaxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n let smallWidth = 0\n let currentWidth = 0\n let top = 0\n smallBoxes.forEach(box => {\n if (box.top !== top) {\n currentWidth = 0\n top = box.top\n }\n currentWidth += box.width\n smallWidth = Math.max(smallWidth, currentWidth)\n })\n bigWidth = Math.max(bigWidth, containerWidth - smallWidth);\n }\n offsetLeft = bigWidth;\n bigOffsetLeft = containerWidth - offsetLeft;\n if (bigFirst === 'column') {\n showBigFirst = true;\n } else if (bigFirst === 'row') {\n showBigFirst = false;\n }\n }\n if (showBigFirst) {\n areas.big = {\n top: 0,\n left: 0,\n width: bigWidth,\n height: bigHeight,\n };\n areas.small = {\n top: offsetTop,\n left: offsetLeft,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n } else {\n areas.big = {\n left: bigOffsetLeft,\n top: bigOffsetTop,\n width: bigWidth,\n height: bigHeight,\n };\n areas.small = {\n top: 0,\n left: 0,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n }\n } else if (bigOnes.length > 0 && smallOnes.length === 0) {\n // We only have one bigOne just center it\n areas.big = {\n top: 0,\n left: 0,\n width: containerWidth,\n height: containerHeight,\n };\n } else {\n areas.small = {\n top: offsetTop,\n left: offsetLeft,\n width: containerWidth - offsetLeft,\n height: containerHeight - offsetTop,\n };\n }\n\n if (areas.big) {\n bigBoxes = getLayout({\n containerWidth: areas.big.width,\n containerHeight: areas.big.height,\n offsetLeft: areas.big.left,\n offsetTop: areas.big.top,\n fixedRatio: bigFixedRatio,\n minRatio: bigMinRatio,\n maxRatio: bigMaxRatio,\n alignItems: bigAlignItems,\n maxWidth: bigMaxWidth,\n maxHeight: bigMaxHeight,\n scaleLastRow: bigScaleLastRow,\n evenRows,\n }, bigOnes);\n }\n if (areas.small) {\n smallBoxes = getLayout({\n containerWidth: areas.small.width,\n containerHeight: areas.small.height,\n offsetLeft: areas.small.left,\n offsetTop: areas.small.top,\n fixedRatio,\n minRatio,\n maxRatio,\n alignItems: areas.big ? smallAlignItems : alignItems,\n maxWidth: areas.big ? smallMaxWidth : maxWidth,\n maxHeight: areas.big ? smallMaxHeight : maxHeight,\n scaleLastRow,\n evenRows,\n }, smallOnes);\n }\n\n const boxes: Box[] = [];\n let bigBoxesIdx = 0;\n let smallBoxesIdx = 0;\n // Rebuild the array in the right order based on where the bigIndices should be\n elements.forEach((element, idx) => {\n if (bigIndices.indexOf(idx) > -1) {\n boxes[idx] = bigBoxes[bigBoxesIdx];\n bigBoxesIdx += 1;\n } else {\n boxes[idx] = smallBoxes[smallBoxesIdx];\n smallBoxesIdx += 1;\n }\n });\n return { boxes, areas };\n};\n","/// \n/*!\n * opentok-layout-js (http://github.com/aullman/opentok-layout-js)\n *\n * Automatic layout of video elements (publisher and subscriber) minimising\n * white-space for the OpenTok on WebRTC API.\n *\n * @Author: Adam Ullman (http://github.com/aullman)\n * @Copyright (c) 2014 Adam Ullman\n * @License: Released under the MIT license (http://opensource.org/licenses/MIT)\n * */\n\n// in CommonJS context, this should be a `require()`d dependency.\n// in browser globals context, ...? (when using bower, there are dependencies that it has handled\n// for you, so these might be safe to assume)\n\nimport getLayout from './getLayout'\nimport layout from './layout'\nimport type { Options, LayoutContainer } from 'opentok-layout-js'\n\ndeclare global {\n interface Window {\n HTMLElement: typeof HTMLElement;\n }\n}\n\nmodule.exports = function initLayoutContainer(container: HTMLElement | Options, options: Options): LayoutContainer {\n let opts = options;\n const win = (opts && opts.window) || (typeof window === 'undefined' ? undefined : window);\n container = typeof container === 'string' ? win.document.querySelector(container) : container;\n if (!(typeof (win && win.HTMLElement) === 'undefined' || container instanceof win.HTMLElement) && !opts) {\n // container is actually the options\n opts = container as Options;\n } else if (!opts) {\n opts = {};\n }\n const setOptions = (newOptions) => {\n opts = newOptions;\n };\n\n return {\n layout: () => {\n return layout.apply(this, [container, opts])\n },\n getLayout: (...args) => {\n console.log('getLayout apply');\n return getLayout.apply(this, [opts, ...args]);\n },\n setOptions,\n };\n};\n","/// \n\nimport { Options, Element, OnLayout, Animate, AnimateProps } from 'opentok-layout-js';\nimport getLayout from './getLayout';\n\nexport default (container: HTMLElement, opts: Options) => {\n function css(el: HTMLElement, propertyName: Record): typeof NaN\n function css(el: HTMLElement, propertyName: string, value: string): typeof NaN\n function css(el: HTMLElement, propertyName: string): string\n function css(el: HTMLElement, propertyName: string | Record, value?: string) {\n if (typeof propertyName === 'string' && value) {\n // We are setting one css property\n el.style[propertyName] = value;\n return NaN;\n }\n if (typeof propertyName === 'object') {\n // We are setting several CSS properties at once\n Object.keys(propertyName).forEach((key) => {\n css(el, key, propertyName[key]);\n });\n return NaN;\n }\n // We are getting the css property\n const computedStyle = ((opts && opts.window) || window).getComputedStyle(el);\n let currentValue = computedStyle.getPropertyValue(propertyName);\n\n if (currentValue === '') {\n currentValue = el.style[propertyName];\n }\n\n return currentValue;\n }\n\n const filterDisplayNone = element => css(element, 'display') !== 'none';\n\n function height(el) {\n if (el.offsetHeight > 0) {\n return `${el.offsetHeight}px`;\n }\n return css(el, 'height');\n }\n\n function width(el) {\n if (el.offsetWidth > 0) {\n return `${el.offsetWidth}px`;\n }\n return css(el, 'width');\n }\n\n const positionElement = function positionElement(elem: HTMLElement, x: number, y: number, w: number, h: number, animate: Animate, onLayout: OnLayout) {\n const targetPosition = {\n left: `${x}px`,\n top: `${y}px`,\n width: `${w}px`,\n height: `${h}px`,\n };\n\n const fixAspectRatio = function fixAspectRatio() {\n const sub = elem.querySelector('.OT_root') as HTMLElement;\n if (sub) {\n // If this is the parent of a subscriber or publisher then we need\n // to force the mutation observer on the publisher or subscriber to\n // trigger to get it to fix it's layout\n const oldWidth = sub.style.width;\n sub.style.width = `${w}px`;\n // sub.style.height = height + 'px';\n sub.style.width = oldWidth || '';\n }\n };\n\n if (animate && typeof $ !== 'undefined') {\n $(elem).stop();\n const animateProps: AnimateProps = typeof animate === 'boolean' ? { duration: 200, easing: 'swing' } : animate;\n $(elem).animate(targetPosition, animateProps.duration, animateProps.easing,\n () => {\n fixAspectRatio();\n if (animateProps.complete) animateProps.complete.call(this);\n if (onLayout) {\n onLayout(elem, {\n left: x,\n top: y,\n width: w,\n height: h,\n });\n }\n });\n } else {\n css(elem, targetPosition);\n if (!elem.classList.contains('ot-layout')) {\n elem.classList.add('ot-layout');\n }\n if (onLayout) {\n onLayout(elem, {\n left: x,\n top: y,\n width: w,\n height: h,\n });\n }\n }\n fixAspectRatio();\n };\n\n const getChildDims = function getChildDims(child: HTMLVideoElement | HTMLElement): Omit {\n if (child) {\n if ((child as HTMLVideoElement).videoHeight && (child as HTMLVideoElement).videoWidth) {\n return {\n height: (child as HTMLVideoElement).videoHeight,\n width: (child as HTMLVideoElement).videoWidth,\n };\n }\n const video = child.querySelector('video');\n if (video && video.videoHeight && video.videoWidth) {\n return {\n height: video.videoHeight,\n width: video.videoWidth,\n };\n }\n }\n return {\n height: 480,\n width: 640,\n };\n };\n\n const getCSSNumber = function getCSSNumber(elem: HTMLElement, prop: string) {\n const cssStr = css(elem, prop);\n return cssStr ? parseInt(cssStr, 10) : 0;\n };\n\n // Really cheap UUID function\n const cheapUUID = function cheapUUID() {\n return (Math.random() * 100000000).toFixed(0);\n };\n\n const getHeight = function getHeight(elem) {\n const heightStr = height(elem);\n return heightStr ? parseInt(heightStr, 10) : 0;\n };\n\n const getWidth = function getWidth(elem) {\n const widthStr = width(elem);\n return widthStr ? parseInt(widthStr, 10) : 0;\n };\n\n const {\n animate = false,\n bigClass = 'OT_big',\n ignoreClass = 'OT_ignore',\n fixedRatioClass = 'OT_fixedRatio',\n } = opts;\n\n if (css(container, 'display') === 'none') {\n return;\n }\n let id = container.getAttribute('id');\n if (!id) {\n id = `OT_${cheapUUID()}`;\n container.setAttribute('id', id);\n }\n\n opts.containerHeight = getHeight(container)\n - getCSSNumber(container, 'border-top')\n - getCSSNumber(container, 'border-bottom');\n opts.containerWidth = getWidth(container)\n - getCSSNumber(container, 'border-left')\n - getCSSNumber(container, 'border-right');\n\n const children: HTMLElement[] = Array.prototype.filter.call(\n container.querySelectorAll(`#${id}>*:not(.${ignoreClass})`),\n filterDisplayNone\n );\n const elements: Element[] = children.map((element) => {\n return {\n ...getChildDims(element),\n big: element.classList.contains(bigClass),\n fixedRatio: element.classList.contains(fixedRatioClass),\n };\n });\n\n const layout = getLayout(opts, elements);\n layout.boxes.forEach((box, idx) => {\n const elem = children[idx];\n css(elem, 'position', 'absolute');\n const actualWidth = box.width\n - getCSSNumber(elem, 'margin-left')\n - getCSSNumber(elem, 'margin-right')\n - (css(elem, 'box-sizing') !== 'border-box'\n ? (getCSSNumber(elem, 'padding-left')\n + getCSSNumber(elem, 'padding-right')\n + getCSSNumber(elem, 'border-left')\n + getCSSNumber(elem, 'border-right'))\n : 0);\n\n const actualHeight = box.height\n - getCSSNumber(elem, 'margin-top')\n - getCSSNumber(elem, 'margin-bottom')\n - (css(elem, 'box-sizing') !== 'border-box'\n ? (getCSSNumber(elem, 'padding-top')\n + getCSSNumber(elem, 'padding-bottom')\n + getCSSNumber(elem, 'border-top')\n + getCSSNumber(elem, 'border-bottom'))\n : 0);\n\n positionElement(elem, box.left, box.top, actualWidth, actualHeight,\n animate, opts.onLayout);\n });\n};\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 5495257..dd7cfec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,8 @@ declare global { } } -module.exports = function initLayoutContainer(container: HTMLElement | Options, opts: Options): LayoutContainer { +module.exports = function initLayoutContainer(container: HTMLElement | Options, options: Options): LayoutContainer { + let opts = options; const win = (opts && opts.window) || (typeof window === 'undefined' ? undefined : window); container = typeof container === 'string' ? win.document.querySelector(container) : container; if (!(typeof (win && win.HTMLElement) === 'undefined' || container instanceof win.HTMLElement) && !opts) { @@ -33,9 +34,18 @@ module.exports = function initLayoutContainer(container: HTMLElement | Options, } else if (!opts) { opts = {}; } + const setOptions = (newOptions) => { + opts = newOptions; + }; return { - layout: layout.bind(this, container, opts), - getLayout: getLayout.bind(this, opts), + layout: () => { + return layout.apply(this, [container, opts]) + }, + getLayout: (...args) => { + console.log('getLayout apply'); + return getLayout.apply(this, [opts, ...args]); + }, + setOptions, }; }; diff --git a/tests/unit/opentok-layout-spec.js b/tests/unit/opentok-layout-spec.js index 3a5a856..29bfdc7 100644 --- a/tests/unit/opentok-layout-spec.js +++ b/tests/unit/opentok-layout-spec.js @@ -4,13 +4,14 @@ describe('opentok layout', () => { expect(typeof window.initLayoutContainer).toEqual('function'); }); - it('defines layout and getLayout methods', () => { + it('defines layout, getLayout and setOptions methods', () => { const layoutDiv = document.createElement('div'); document.body.appendChild(layoutDiv); const layoutContainer = initLayoutContainer(layoutDiv); expect(typeof layoutContainer.layout).toEqual('function'); expect(typeof layoutContainer.getLayout).toEqual('function'); + expect(typeof layoutContainer.setOptions).toEqual('function'); }); it('does not break jQuery', () => { @@ -162,6 +163,21 @@ describe('opentok layout', () => { expect(div1Rect.width / div1Rect.height).toBeCloseTo(16 / 9, 3); }); + describe('setOptions', () => { + it('lets you update min and maxRatio options', () => { + const layoutContainer = initLayoutContainer(layoutDiv, + { minRatio: 9 / 16, maxRatio: 9 / 16 }); + layoutContainer.layout(); + const div1Rect = div1.getBoundingClientRect(); + expect(div1Rect.width / div1Rect.height).toBeCloseTo(16 / 9, 3); + + layoutContainer.setOptions({ minRatio: 3 / 4, maxRatio: 3 / 4 }); + layoutContainer.layout(); + const updatedDiv1Rect = div1.getBoundingClientRect(); + expect(updatedDiv1Rect.width / updatedDiv1Rect.height).toBeCloseTo(4 / 3, 3); + }); + }); + describe('alignItems', () => { ['start', 'center', 'end'].forEach((alignItems) => { it(`Handles ${alignItems}`, () => { @@ -272,6 +288,62 @@ describe('opentok layout', () => { }); }); + it('lets you update container size for getLayout', () => { + const layoutContainer = initLayoutContainer({ + containerWidth: 400, + containerHeight: 300, + }); + + expect(layoutContainer.getLayout(children.map(child => ({ + width: 640, + height: 480, + big: child.className === 'OT_big', + })))).toEqual({ + boxes: expectedLayout, + areas: { + big: { + top: 0, left: 0, width: 320, height: 300, + }, + small: { + top: 0, left: 320, width: 80, height: 300, + }, + }, + }); + + layoutContainer.setOptions({ + containerWidth: 800, + containerHeight: 600, + }); + + expect(layoutContainer.getLayout(children.map(child => ({ + width: 640, + height: 480, + big: child.className === 'OT_big', + })))).toEqual({ + boxes: [{ + width: 640, + height: 600, + left: 0, + top: 0, + }, + { + width: 160, + height: 240, + left: 640, + top: 180, + }, + ], + areas: { + big: { + top: 0, left: 0, width: 640, height: 600, + }, + small: { + top: 0, left: 640, width: 160, height: 600, + }, + }, + }); + }); + it('handles default layout', () => { const layoutContainer = initLayoutContainer(layoutDiv); layoutContainer.layout(); diff --git a/types/opentok-layout-js.d.ts b/types/opentok-layout-js.d.ts index a58b6e0..37d022b 100644 --- a/types/opentok-layout-js.d.ts +++ b/types/opentok-layout-js.d.ts @@ -54,10 +54,12 @@ declare module 'opentok-layout-js' { export type GetLayoutRes = { boxes: Array, areas: { small?: Box, big?: Box } } type GetLayout = (elements: Array) => GetLayoutRes; + export type SetOptions = (options: Options) => void; export type LayoutContainer = { getLayout: GetLayout; layout: () => void; + setOptions: SetOptions; }; export default function initLayoutContainer(...args: [HTMLElement | string, Options] | [Options]): LayoutContainer;