troika-core
Advanced tools
Comparing version 0.15.6 to 0.16.0
@@ -1,56 +0,56 @@ | ||
'use strict';(function(u,A){"object"===typeof exports&&"undefined"!==typeof module?A(exports,require("troika-animation"),require("react"),require("prop-types")):"function"===typeof define&&define.amd?define(["exports","troika-animation","react","prop-types"],A):(u=u||self,A(u.troika_core={},u.troika_animation,u.React,u.PropTypes))})(this,function(u,A,m,q){function P(){for(var c=arguments,b=arguments[0],a=1,d=arguments.length;a<d;a++){var f=c[a];if(f)for(var n in f)f.hasOwnProperty(n)&&(b[n]=f[n])}return b} | ||
function Q(){for(var c=arguments,b=arguments[0],a=1,d=arguments.length;a<d;a++){var f=c[a];if(f)for(var n in f)f.hasOwnProperty(n)&&!b.hasOwnProperty(n)&&(b[n]=f[n])}return b}function R(c,b){if(b)for(var a in b)b.hasOwnProperty(a)&&(c[a]&&"object"===typeof c[a]&&"object"===typeof b[a]?R(c[a],b[a]):c[a]=b[a])}function F(c,b){var a=new WeakMap;return function(d){var f=a.get(d);f||(f=b(d),a.set(d,f));return f}}function S(c){return(c=c.$$typeof)&&c.toString&&"Symbol(react.element)"===c.toString()||!1} | ||
function ca(c,b){return"paused"===c?void 0:Infinity===b?"Infinity":b}function da(c,b){return c.time-b.time}function G(c){return"onDoubleClick"===c?"dblclick":c.replace(/^on/,"").toLowerCase()}function ea(){var c=this,b=Object.create(null);this.addListenerForFacade=function(a,d,f){d=b[d]||(b[d]={count:0,byFacadeId:Object.create(null)});a=a.$facadeId;var c=d.byFacadeId[a];c?Array.isArray(c)?-1===c.indexOf(f)&&(d.count++,c.push(f)):c!==f&&(d.count++,d.byFacadeId[a]=[c,f]):(d.count++,d.byFacadeId[a]= | ||
f)};this.removeListenerForFacade=function(a,d,f){d=b[d];a=a.$facadeId;var c=d&&d.byFacadeId[a];c===f?(d.count--,delete d.byFacadeId[a]):Array.isArray(c)&&(f=c.indexOf(f),-1<f&&(d.count--,1===c.length?delete d.byFacadeId[a]:c.splice(f,1)))};this.removeAllListenersForFacade=function(a){a=a.$facadeId;for(var d in b){var f=b[d].byFacadeId[a];f&&(b[d].count-=Array.isArray(f)?f.length:1,delete b[d].byFacadeId[a])}};this.hasFacadeListenersOfType=function(a,d){return b[d]?!!b[d].byFacadeId[a.$facadeId]:!1}; | ||
this.hasAnyListenersOfType=function(a){return b[a]?0<b[a].count:!1};this.forEachFacadeListenerOfType=function(a,d,f,c){d=b[d];a=a.$facadeId;if(d=d&&d.byFacadeId[a])if(Array.isArray(d))for(var e=0;e<d.length;e++)f.call(c,d[e],a);else f.call(c,d,a)};this.forEachListenerOfType=function(a,d,f){if((a=b[a])&&0<a.count)for(var c in a.byFacadeId){var e=a.byFacadeId[c];if(Array.isArray(e))for(var g=0;g<e.length;g++)d.call(f,e[g],c);else d.call(f,e,c)}};this.dispatchEventOnFacade=function(a,d){function f(a){a.call(b, | ||
d)}var b=a;for(d.target=a;b&&!d.propagationStopped;)if(d.currentTarget=b,c.forEachFacadeListenerOfType(b,d.type,f,null),d.bubbles)b=b.parent;else break}}function H(c){return"touchend"===c.type||"touchcancel"===c.type}function fa(c){c.stopPropagation();c.preventDefault()}m=m&&m.hasOwnProperty("default")?m["default"]:m;q=q&&q.hasOwnProperty("default")?q["default"]:q;var B=Object.assign||P,I=function(){var c=new WeakMap,b=0;return function(a){var d=c.get(a);d||c.set(a,d="$id"+ ++b);return d}}();I=Object.freeze({assign:B, | ||
_assign:P,assignIf:Q,assignDeep:R,forOwn:function(c,b,a){for(var d in c)c.hasOwnProperty(d)&&b.call(a,c[d],d,c)},getIdForObject:I,createClassExtender:F,isReactElement:S});var k=function(c){this.$facadeId="facade"+ha++;this.parent=c};k.prototype.afterUpdate=function(){var c=this.ref;c!==this._lastRef&&("function"===typeof this._lastRef&&this._lastRef.call(null,null),"function"===typeof c?(c.call(null,this),this._lastRef=c):this._lastRef=null)};k.prototype.notifyWorld=function(c,b){if(this.parent)this.parent.onNotifyWorld(this, | ||
c,b)};k.prototype.onNotifyWorld=function(c,b,a){var d=this._notifiableParent;if(d)d.onNotifyWorld.call(d,c,b,a);else{d=this.parent;for(var f=k.prototype.onNotifyWorld;d;){if(d.onNotifyWorld!==f){this._notifiableParent=d;d.onNotifyWorld(c,b,a);break}d=d.parent}}};k.prototype.traverse=function(c){c(this)};k.prototype.forEachChild=function(c){};k.prototype.addEventListener=function(c,b){this.notifyWorld("addEventListener",{type:c,handler:b})};k.prototype.removeEventListener=function(c,b){this.notifyWorld("removeEventListener", | ||
{type:c,handler:b})};k.prototype.dispatchEvent=function(c){this.notifyWorld("dispatchEvent",c)};k.prototype.destructor=function(){this.parent&&this.notifyWorld("removeAllEventListeners");"function"===typeof this.ref&&this.ref.call(null,null);this.parent=this._notifiableParent=null};B(k.prototype,{ref:null,_lastRef:null,_notifiableParent:null});var ha=0,ia={key:1,facade:1,transition:1,animation:1};k.isSpecialDescriptorProperty=function(c){return ia.hasOwnProperty(c)};k.defineEventProperty=function(c, | ||
b,a){var d=b+"\u27a4handler";Object.defineProperty(c.prototype,b,{get:function(){return this[d]},set:function(b){var c=this[d];(b||null)!==(c||null)&&("function"===typeof c&&this.removeEventListener(a,c),"function"===typeof b&&this.addEventListener(a,b),this[d]=b)}})};var T=[null],U=F("animatable",function(c){function b(d,b){if(!a.prototype.hasOwnProperty(d)){for(var f=d+"\u27a4anim:actualValue",e=d+"\u27a4anim:actuallySet",g=d+"\u27a4anim:hasBeenSet",L=d+"\u27a4anim:tween",h,l,t=c.prototype;t;){var J= | ||
Object.getOwnPropertyDescriptor(t,d);if(J){l=J.set;h=J.get;if(l&&!h||h&&!l)throw Error("Animatable: property "+d+" has a custom "+(l?"setter":"getter")+" but no "+(l?"getter":"setter")+". Animatable properties must have both.");break}t=Object.getPrototypeOf(t)}var p=l?function(a){l.call(this,a);this[g]||(this[g]=!0)}:function(a){this[f]=a;this[g]||(this[g]=!0)};Object.defineProperty(a.prototype,e,{value:p});Object.defineProperty(a.prototype,d,{get:function(){return h?h.call(this):this[g]?this[f]: | ||
c.prototype[d]},set:function(a){if(!this.animation$animatingProps||!this.animation$animatingProps[d]){var b=this.animation$runner,c=this.transition;if(c&&c[d]&&this[g]&&c.hasOwnProperty(d)){c=c[d];var f=this[L],e=!1;f?a!==f.toValue&&(b.stop(f),e=!0):a!==this[d]&&(e=!0);e&&(f=this[L]=new A.Tween(p.bind(this),this[d],a,c.duration||750,c.delay||0,c.easing||"easeOutCubic",1,"forward",c.interpolate||"number"),b.start(f))}else p.call(this,a),(a=this[L])&&b.stop(a),this[L]=null}}})}b.hasOwnProperty(d)&& | ||
(b[d+"\u27a4anim:actualValue"]=b[d],delete b[d])}var a=function(a){function d(){for(var d=this,b=[],c=arguments.length;c--;)b[c]=arguments[c];a.apply(this,b);this.animation$runner=new A.Runner;this.animation$runner.onTick=function(){d.afterUpdate();d.notifyWorld("needsRender")}}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor=d;var c={transition:{configurable:!0},animation:{configurable:!0}};c.transition.set=function(a){if(a)for(var d in a)a.hasOwnProperty(d)&& | ||
b(d,this);this.transition$descriptor=a};c.transition.get=function(){return this.transition$descriptor};c.animation.set=function(a){if(this.animation$descriptor!==a){this.animation$descriptor=a;var d=this.animation$tweens||null,c=this.animation$tweens=a?Object.create(null):null,f=this.animation$runner,e=!1;a&&!Array.isArray(a)&&(T[0]=a,a=T);if(a)for(var n=0,J=a.length;n<J;n++){var p=a[n];if(p){var v=JSON.stringify(p,ca);if(d&&v in d){var r=d[v];p.paused?f.pause(r):f.start(r);c[v]=r}else{e=0;var m= | ||
750,q="linear",k=1;r=[];var u="forward",w;for(w in p)if(p.hasOwnProperty(w))switch(w){case "duration":m=p[w];break;case "delay":e=p[w];break;case "easing":q=p[w];break;case "iterations":k=p[w];break;case "direction":u=p[w];break;default:var z="from"===w?0:"to"===w?100:parseFloat(w);if(!isNaN(z)&&0<=z&&100>=z){r.push({time:z/100,props:p[w]});for(var x in p[w])p[w].hasOwnProperty(x)&&(b(x,this),z=x+"\u27a4anim:tween",this[z]&&(f.stop(this[z]),this[z]=null))}}if(r.length){r.sort(da);0<r[0].time&&r.unshift(Q({time:0}, | ||
r[0]));z=[];for(var y=1,B=r.length;y<B;y++){var E=r[y],F=E.props,C;for(C in F)if(F.hasOwnProperty(C)){for(var D=null,G=y;G--;)if(C in r[G].props){D=r[G];break}D&&(D=new A.Tween(this[C+"\u27a4anim:actuallySet"].bind(this),D.props[C],F[C],(E.time-D.time)*m,D.time*m,"linear",1,"forward",p.interpolate&&p.interpolate[C]||"number"),D.$$property=C,z.push(D))}}v=c[v]=new A.MultiTween(z,m,e,q,k,u);p.paused||f.start(v);if(0===e){p=r[0].props;for(var H in p)if(p.hasOwnProperty(H))this[H+"\u27a4anim:actuallySet"](p[H])}}e= | ||
!0}}}if(d)for(var K in d)c&&c[K]||(a=d[K],a.gotoEnd(),f.stop(a),e=!0);if(e)if(c){d=this.animation$animatingProps=Object.create(null);for(var I in c)for(f=c[I].tweens,K=f.length;K--;)d[f[K].$$property]=!0}else this.animation$animatingProps=null}};c.animation.get=function(){return this.animation$descriptor};d.prototype.destructor=function(){var d=this,c=this.animation$runner;if(this.exitAnimation&&!this.parent.isDestroying){c.stopAll();this.animation=this.exitAnimation;this.exitAnimation=this.transition= | ||
null;var b=c.onTick;c.onTick=function(){d.parent&&!d.parent.isDestroying?b():(c.onDone=null,d.destructor())};c.onDone=function(){d.notifyWorld("needsRender");d.destructor()}}else c.destructor(),a.prototype.destructor.call(this)};Object.defineProperties(d.prototype,c);return d}(c);return a}),V=F("pointerStates",function(c){function b(a,d){var b=a+"\u27a4pntr:hasBeenSet";d[b]||(d[a+"\u27a4pntr:baseValue"]=d[a],delete d[a],d[b]=!0);if(!h.prototype.hasOwnProperty(a)){m[a]=1;var f=a+"\u27a4pntr:baseValue", | ||
e=a+"\u27a4pntr:appliedValue";Object.defineProperty(h.prototype,a,{get:function(){a:{var d=c.prototype;if(a in d)for(;d;){var b=Object.getOwnPropertyDescriptor(d,a);if(b&&b.get){d=b.get;break a}d=Object.getPrototypeOf(d)}d=null}return d?d.call(this):e in this?this[e]:this[f]},set:function(a){this[f]=a}})}}function a(a,d,b){a:{var f=c.prototype;if(d in f)for(;f;){var e=Object.getOwnPropertyDescriptor(f,d);if(e&&e.set){f=e.set;break a}f=Object.getPrototypeOf(f)}f=null}f?f.call(a,b):a[d+"\u27a4pntr:appliedValue"]= | ||
b}function d(a){a.currentTarget["\u27a4pntr:isHovering"]=!0;g(a)}function f(a){a.currentTarget["\u27a4pntr:isHovering"]=a.currentTarget["\u27a4pntr:isActive"]=!1;g(a)}function n(a){a.currentTarget["\u27a4pntr:isActive"]=!0;g(a)}function e(a){a.currentTarget["\u27a4pntr:isActive"]=!1;g(a)}function g(a){a=a.currentTarget;for(var d=a.parent;d&&d.shouldUpdateChildren();)d.isPointerStateAware&&(a=d),d=d.parent;a.afterUpdate();a.notifyWorld("needsRender")}var m=Object.create(null),h=function(c){function g(a){c.call(this, | ||
a);this.addEventListener("mouseover",d);this.addEventListener("mouseout",f);this.addEventListener("mousedown",n);this.addEventListener("mouseup",e)}c&&(g.__proto__=c);g.prototype=Object.create(c&&c.prototype);g.prototype.constructor=g;g.prototype.afterUpdate=function(){this._applyPointerStates();c.prototype.afterUpdate.call(this)};g.prototype._applyPointerStates=function(){var d=this.pointerStates,c=d&&this["\u27a4pntr:isHovering"]&&d.hover||null,f=d&&this["\u27a4pntr:isActive"]&&d.active||null;d= | ||
this["\u27a4pntr:lastAppliedValues"]||m;if(c=this["\u27a4pntr:lastAppliedValues"]=c||f?B(Object.create(null),c,f):null)for(var e in c)b(e,this),a(this,e,c[e]);if(d)for(var n in d)c&&n in c||a(this,n,this[n+"\u27a4pntr:baseValue"])};return g}(c);Object.defineProperty(h.prototype,"isPointerStateAware",{value:!0});return h}),ja=function(c){function b(a){c.call(this,a);this._orderedItemKeys=[]}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate= | ||
function(){var a=this.data,d=this.template,b=a&&a.length&&Array.isArray(a);if("production"!==process.env.NODE_ENV){if(a&&!Array.isArray(a))throw Error('ListFacade "data" must be an array.');if(!d||"object"!==typeof d)throw Error('ListFacade "template" must be an object.');if(!d||"function"!==typeof d.key)throw Error('ListFacade template must define a "key" function.');if(!d||"function"!==typeof d.facade)throw Error('ListFacade template must define a "facade".');}if(this.shouldUpdateChildren()){var n= | ||
this._itemsDict||null,e=this._itemsDict=b?Object.create(null):null,g=this._orderedItemKeys;if(b){g.length=a.length;b=0;for(var m=a.length;b<m;b++){var h=a[b],l=d.key(h,b,a),t=d.facade;if("production"!==process.env.NODE_ENV){if(null==l)throw Error('ListFacade template "key" function must return a key.');e[l]&&console.warn("Duplicate key in list: "+l)}for(;e[l];)l+="|dupe";var q="function"===typeof d.transition?d.transition(h,b,a):d.transition,p="function"===typeof d.animation?d.animation(h,b,a):d.animation, | ||
v="function"===typeof d.exitAnimation?d.exitAnimation(h,b,a):d.exitAnimation;if(q||p||v)t=U(t);v=d.pointerStates;if("function"===v?v(h,b,a):v)t=V(t);(v=n&&n[l])&&v.constructor===t?t=v:(v&&v.destructor(),t=new t(this));t.transition=q;t.animation=p;for(var r in d)d.hasOwnProperty(r)&&!c.isSpecialDescriptorProperty(r)&&(t[r]="function"===typeof d[r]?d[r](h,b,a):d[r]);t.afterUpdate();e[l]=t;g[b]=l}}if(n)for(var k in n)e&&e[k]||n[k].destructor()}c.prototype.afterUpdate.call(this)};b.prototype.shouldUpdateChildren= | ||
function(){return!0};b.prototype.traverse=function(a,d){a.call(d,this);for(var c=this._orderedItemKeys,b=this._itemsDict,e=0,g=c.length;e<g;e++)b[c[e]].traverse(a,d)};b.prototype.forEachChild=function(a,d){for(var c=this._orderedItemKeys,b=this._itemsDict,e=0,g=c.length;e<g;e++)a.call(d,b[c[e]],c[e])};b.prototype.destructor=function(){this.isDestroying=!0;var a=this._itemsDict;if(a)for(var d in a)a[d].destructor();c.prototype.destructor.call(this)};return b}(k),W=[null],M=function(c){function b(a){c.call(this, | ||
a);this.children=null;this._orderedChildKeys=[]}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate=function(){this.shouldUpdateChildren()&&this.updateChildren(this.children);c.prototype.afterUpdate.call(this)};b.prototype.shouldUpdateChildren=function(){return!0};b.prototype.updateChildren=function(a){var d=this._childrenDict||null,b=this._childrenDict=null,n=this._orderedChildKeys;if(a){Array.isArray(a)||(W[0]=a,a=W);for(var e=0,g=0,m=a.length;g< | ||
m;g++){var h=a[g];if(h){b||(b=this._childrenDict=Object.create(null));var l=S(h),t=l?h.props:h;l=l?h.type:h.facade;h=h.key;if(!h){var q=0;do h="auto:"+l.name+":"+q++;while(b[h])}if("production"!==process.env.NODE_ENV&&"function"!==typeof l)throw Error('All scene objects must have a "facade" property pointing to a class/constructor');if(b[h])for(console.warn("Duplicate key in children: "+h);b[h];)h+="|dupe";q=t.transition;var p=t.animation;if(q||p||t.exitAnimation)l=U(l);t.pointerStates&&(l=V(l)); | ||
var k=d&&d[h];k&&k.constructor===l?l=k:(k&&k.destructor(),l=new l(this));l.transition=q;l.animation=p;for(var r in t)t.hasOwnProperty(r)&&!c.isSpecialDescriptorProperty(r)&&(l[r]=t[r]);l.afterUpdate();b[h]=l;n[e++]=h}}n.length=e}else n.length=0;if(d)for(var u in d)b&&b[u]||d[u].destructor()};b.prototype.getChildByKey=function(a){var d=this._childrenDict;return d&&d[a]||null};b.prototype.traverse=function(a,d){a.call(d,this);for(var b=this._orderedChildKeys,c=this._childrenDict,e=0,g=b.length;e<g;e++)c[b[e]].traverse(a, | ||
d)};b.prototype.forEachChild=function(a,d){for(var b=this._orderedChildKeys,c=this._childrenDict,e=0,g=b.length;e<g;e++)a.call(d,c[b[e]],b[e])};b.prototype.destructor=function(){this.isDestroying=!0;var a=this._childrenDict;if(a)for(var d in a)a[d].destructor();c.prototype.destructor.call(this)};return b}(k),x="onMouseOver onMouseOut onMouseMove onDragStart onDrag onDragEnter onDragOver onDragLeave".split(" "),E="onMouseDown onMouseUp onClick onDoubleClick onDrop onDragEnd onWheel".split(" "),X=E.map(G), | ||
Y=x.map(G);x=x.concat(E);var Z=Y.concat(X),N=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.interceptsPointerEvents=function(a){if(!1===this.pointerEvents)return!1;if(this.pointerEvents)return!0;for(var d=0,b=Z.length;d<b;d++)if(a.hasFacadeListenersOfType(this,Z[d]))return!0};return b}(M);Object.defineProperty(N.prototype,"isPointerEventTarget",{value:!0});x.forEach(function(c){k.defineEventProperty(N, | ||
c,G(c))});var ka={},la=["mousemove","mouseout","touchmove"],ma="mousedown mouseup click dblclick wheel touchstart touchend touchcancel".split(" "),aa=["mouseup","touchend","touchcancel"],na={touchstart:"mousedown",touchend:"mouseup",touchcancel:"mouseup"},oa="clientX clientY screenX screenY pageX pageY".split(" "),y=function(c,b,a,d,f){var n=this,e;for(e in c)"function"!==typeof c[e]&&(n[e]=c[e]);this.target=a;this.relatedTarget=d;this.type=b;this.nativeEvent=c;B(this,f);if(c.touches){var g=H(c)? | ||
c.changedTouches:c.touches;1===g.length&&oa.forEach(function(a){n[a]=g[0][a]})}};y.prototype.preventDefault=function(){this.defaultPrevented=!0;this.nativeEvent.preventDefault()};y.prototype.stopPropagation=function(){this.propagationStopped=!0;this.nativeEvent.stopPropagation()};x=function(c){function b(a){c.call(this,null);this.width=this.height=1;this._element=a;this._htmlOverlays=Object.create(null);this.eventRegistry=new ea;this._onPointerMotionEvent=this._onPointerMotionEvent.bind(this);this._onPointerActionEvent= | ||
this._onPointerActionEvent.bind(this);this._onDropEvent=this._onDropEvent.bind(this);this._togglePointerListeners(!0)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate=function(){this._queueRender();c.prototype.afterUpdate.call(this)};b.prototype.onNotifyWorld=function(a,d,b){(d=this._notifyWorldHandlers[d])&&d.call(this,a,b)};b.prototype._isContinuousRender=function(){return this.continuousRender};b.prototype._requestRenderFrame=function(a){return window.requestAnimationFrame(a)}; | ||
b.prototype._cancelAnimationFrame=function(a){return window.cancelAnimationFrame(a)};b.prototype._queueRender=function(){var a=this;this._nextFrameTimer||(this._nextFrameTimer=this._requestRenderFrame(this._nextFrameHandler||(this._nextFrameHandler=function(){for(var d=[],b=arguments.length;b--;)d[b]=arguments[b];b=a.onStatsUpdate;var c=a.onBeforeRender,e=a.onAfterRender,g=b&&Date.now();c&&c(a);a.doRender.apply(a,d);b&&(d=Date.now(),b({"Render CPU Time (ms)":d-g,"Time Between Frames (ms)":a._lastFrameTime? | ||
d-a._lastFrameTime:"?",FPS:a._lastFrameTime?Math.round(1E3/(d-a._lastFrameTime)):"?"}),a._lastFrameTime=d);a._doRenderHtmlItems();e&&e(a);a._nextFrameTimer=null;a._isContinuousRender()&&a._queueRender()})))};b.prototype.doRender=function(){};b.prototype.getFacadeUserSpaceXYZ=function(a){};b.prototype._doRenderHtmlItems=function(){if(this.renderHtmlItems){var a=[],d=this._htmlOverlays,b;for(b in d){var c=d[b],e=this.getFacadeUserSpaceXYZ(c);0<=e.z&&(e.key=c.$facadeId,e.html=c.html,e.exact=c.exact, | ||
a.push(e))}this.renderHtmlItems(a)}};b.prototype._normalizePointerEvent=function(a){};b.prototype._onPointerMotionEvent=function(a){this._normalizePointerEvent(a);var d=this._getPointerEventState(a);if(Y.some(this.eventRegistry.hasAnyListenersOfType)){var b="mouseout"===a.type||H(a)?null:this._findHoverTarget(a),c=d.hoveredFacade,e=d.hoveredFacade=b&&b.facade,g=d.dragInfo;g&&(g.dragStartFired||(this._firePointerEvent("dragstart",g.dragStartEvent,g.draggedFacade,null,b),g.dragStartFired=!0),this._firePointerEvent("drag", | ||
a,g.draggedFacade,null,b));e!==c&&(c&&(this._firePointerEvent("mouseout",a,c,e,b),g&&this._firePointerEvent("dragleave",a,c,e,b)),e&&(this._firePointerEvent("mouseover",a,e,c,b),g&&this._firePointerEvent("dragenter",a,e,c,b)));e&&(this._firePointerEvent("mousemove",a,e,null,b),g&&this._firePointerEvent("dragover",a,e,null,b))}(b=d.tapInfo)&&"touchmove"===a.type&&(a=a.changedTouches[0])&&10<Math.sqrt(Math.pow(a.clientX-b.x,2)+Math.pow(a.clientY-b.y,2))&&(d.tapInfo=null)};b.prototype._onPointerActionEvent= | ||
function(a){this._normalizePointerEvent(a);-1<aa.indexOf(a.type)&&this._onDropEvent(a);"touchstart"===a.type&&(1===a.touches.length&&this._onPointerMotionEvent(a),this._enableContextMenu(!1));var d=this.eventRegistry;if(d.hasAnyListenersOfType("dragstart")||X.some(d.hasAnyListenersOfType)){var b=this._findHoverTarget(a);if(d=b&&b.facade){var c=this._getPointerEventState(a);this._firePointerEvent(na[a.type]||a.type,a,d,null,b);if(this._hasEventHandlerInParentTree(d,"click")||this._hasEventHandlerInParentTree(d, | ||
"dblclick")){var e=c.tapInfo;"touchstart"===a.type&&1===a.touches.length?c.tapInfo={facade:d,x:a.touches[0].clientX,y:a.touches[0].clientY,startTime:Date.now(),isDblClick:e&&300>Date.now()-e.startTime}:e&&e.facade===d&&"touchend"===a.type&&0===a.touches.length&&1===a.changedTouches.length&&300>Date.now()-e.startTime&&(this._firePointerEvent("click",a,d,null,b),e.isDblClick&&this._firePointerEvent("dblclick",a,d,null,b))}!d.onDragStart||"mousedown"!==a.type&&"touchstart"!==a.type||(b=new y(a,"dragstart", | ||
d,null,{intersection:b}),c.dragInfo={draggedFacade:d,dragStartFired:!1,dragStartEvent:b},this._toggleDropListeners(!0))}a.preventDefault()}H(a)&&(1===a.changedTouches.length&&this._onPointerMotionEvent(a),this._enableContextMenu(!0))};b.prototype._onDropEvent=function(a){var d=this._getPointerEventState(a),b=d.dragInfo;if(b){this._normalizePointerEvent(a);var c=this._findHoverTarget(a),e=c&&c.facade;e&&this._firePointerEvent("drop",a,e,null,c);this._firePointerEvent("dragend",a,b.draggedFacade,null, | ||
c);this._toggleDropListeners(!1);d.dragInfo=null}};b.prototype._firePointerEvent=function(a,d,b,c,e){a=d instanceof y?d:new y(d,a,b,c,{bubbles:!0,intersection:e});this.eventRegistry.dispatchEventOnFacade(b,a)};b.prototype._getPointerEventState=function(a){var d=this._pointerEventStates||(this._pointerEventStates=new WeakMap);a=a.eventSource||ka;var b=d.get(a);b||d.set(a,b={});return b};b.prototype._hasEventHandlerInParentTree=function(a,d){for(;a;){if(this.eventRegistry.hasFacadeListenersOfType(d))return!0; | ||
a=a.parent}return!1};b.prototype._toggleDropListeners=function(a){var d=this;aa.forEach(function(b){document[(a?"add":"remove")+"EventListener"](b,d._onDropEvent,!0)})};b.prototype._togglePointerListeners=function(a){var d=this,b=this._element;if(b&&a!==this._pointerListenersAttached){var c=(a?"add":"remove")+"EventListener";la.forEach(function(a){b[c](a,d._onPointerMotionEvent,!1)});ma.forEach(function(a){b[c](a,d._onPointerActionEvent,!1)});this._pointerListenersAttached=a}};b.prototype._enableContextMenu= | ||
function(a){var d=this._element;if(d)d[(a?"remove":"add")+"EventListener"]("contextmenu",fa,!0)};b.prototype.getFacadesAtEvent=function(a,d){throw Error("getFacadesAtEvent: no impl");};b.prototype._findHoverTarget=function(a){var d=this;if(a.touches&&1<a.touches.length)return null;if(a=this.getFacadesAtEvent(a,function(a){return a.isPointerEventTarget&&a.interceptsPointerEvents(d.eventRegistry)})){for(var b=a[0],c=1;c<a.length;c++)if(a[c].distance<b.distance||a[c].distance===b.distance&&(a[c].distanceBias|| | ||
0)<(b.distanceBias||0))b=a[c];return b}return null};b.prototype.destructor=function(){this._nextFrameTimer&&this._cancelAnimationFrame(this._nextFrameTimer);this._togglePointerListeners(!1);this._toggleDropListeners(!1);c.prototype.destructor.call(this)};return b}(M);Object.defineProperty(x.prototype,"isWorld",{value:!0});x.prototype._notifyWorldHandlers={needsRender:function(){this._queueRender()},addEventListener:function(c,b){this.eventRegistry.addListenerForFacade(c,b.type,b.handler)},removeEventListener:function(c, | ||
b){this.eventRegistry.removeListenerForFacade(c,b.type,b.handler)},removeAllEventListeners:function(c){this.eventRegistry.removeAllListenersForFacade(c)},dispatchEvent:function(c,b){b instanceof y||(b=new y(b,b.type,b.target,b.relatedTarget));this.eventRegistry.dispatchEventOnFacade(c,b)},addHtmlOverlay:function(c){this._htmlOverlays[c.$facadeId]=c},removeHtmlOverlay:function(c){delete this._htmlOverlays[c.$facadeId]},statsUpdate:function(c,b){(c=this.onStatsUpdate)&&c(b)}};var pa={position:"absolute", | ||
top:0,right:0,bottom:0,left:0,pointerEvents:"none",transformStyle:"preserve-3d"},O=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.shouldComponentUpdate=function(a){return a.html!==this.props.html||!0===(a.html.props&&a.html.props.shouldUpdateOnMove)};b.prototype.render=function(){var a=this.props.html;return"string"===typeof a?m.createElement("span",null,a):m.cloneElement(a)};return b}(m.Component); | ||
O.displayName="Canvas3D.HtmlOverlayContent";O.propTypes={html:q.node};var ba=function(c){function b(a){c.call(this,a);this.setItems=this.setItems.bind(this);this.state={items:null}}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.shouldComponentUpdate=function(a,b){a=this.state;return b.items&&b.items.length||a.items&&a.items.length};b.prototype.setItems=function(a){var b=this.state.items;(a&&a.length||b&&b.length)&&this.setState({items:a||null})}; | ||
b.prototype.render=function(){var a=this.state.items,b=Math.round;return a&&a.length?m.createElement("div",{className:"troika_html_overlay",style:pa},a.map(function(a){var d=a.key,c=a.html,f=a.x,k=a.y,h=a.z;a.exact||(f=b(f),k=b(k));return m.createElement("div",{key:d,style:{position:"absolute",transform:"translate3d("+f+"px, "+k+"px, "+-h+"px)"}},m.createElement(O,{html:c}))})):null};return b}(m.Component);ba.displayName="Canvas3D.HtmlOverlay";var qa={position:"absolute",top:0,right:0,background:"rgba(0,0,0,.5)", | ||
font:"11px sans-serif",padding:10},ra=function(c){function b(a){c.call(this,a);this.state={stats:{}}}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.setStats=function(a){this.setState({stats:a})};b.prototype.render=function(){var a=this.state.stats;return m.createElement("div",{style:qa},Object.keys(a).sort().map(function(b){return m.createElement("div",{key:b},b,": ",a[b])}))};return b}(m.Component),sa={width:"100%",height:"100%"};E=function(c){function b(a){c.call(this, | ||
a);this._stats={};this.updateStats=this.updateStats.bind(this);this.renderHtmlItems=this.renderHtmlItems.bind(this);this._bindHtmlOverlayRef=this._bindHtmlOverlayRef.bind(this);this._bindCanvasRef=this._bindCanvasRef.bind(this);this._bindStatsRef=this._bindStatsRef.bind(this)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.componentDidUpdate=function(){this.updateWorld()};b.prototype.initWorld=function(a){a=new this.props.worldFacade(a);a.renderHtmlItems= | ||
this.renderHtmlItems;return a};b.prototype.updateWorld=function(){var a=this._world;if(a){var b=this.props,c=b.stats,k=c&&Date.now();a.width=b.width;a.height=b.height;a.pixelRatio=b.pixelRatio;a.continuousRender=b.continuousRender;a.onStatsUpdate=c?this.updateStats:null;B(a,b.worldProps);a.afterUpdate();c&&this.updateStats({"Last World Update (ms)":Date.now()-k})}};b.prototype.destroyWorld=function(){this._world&&(this._world.destructor(),delete this._world);clearTimeout(this._statsDelay)};b.prototype.renderHtmlItems= | ||
function(a){this._htmlOverlayRef&&this._htmlOverlayRef.setItems(a)};b.prototype.updateStats=function(a){var b=this;this._stats=B({},this._stats,a);this._statsDelay||(this._statsDelay=setTimeout(function(){b._statsDelay=null;var a=b._statsRef;a&&a.setStats(b._stats)},250))};b.prototype._bindHtmlOverlayRef=function(a){this._htmlOverlayRef=a};b.prototype._bindCanvasRef=function(a){if(a)try{this._world=this.initWorld(a),this.updateWorld()}catch(f){console.warn("Troika."+this.constructor.displayName+": world init failed, using fallback content.", | ||
f),this._failedWorldInit=!0,this._world=null,this.forceUpdate()}else this.destroyWorld();var b=this.props.onCanvasRef;b&&b(a)};b.prototype._bindStatsRef=function(a){this._statsRef=a};b.prototype.render=function(){var a=this.props;return m.createElement("div",{className:"troika "+(a.className||""),style:{position:"relative",overflow:"hidden",width:a.width,height:a.height,cursor:a.cursor,userSelect:"none"}},this._failedWorldInit?this.props.children:m.createElement("canvas",{className:"troika_canvas", | ||
ref:this._bindCanvasRef,style:a.canvasStyle||sa}),m.createElement(ba,{ref:this._bindHtmlOverlayRef}),a.stats?m.createElement(ra,{ref:this._bindStatsRef}):null)};return b}(m.Component);E.commonPropTypes={width:q.number.isRequired,height:q.number.isRequired,pixelRatio:q.number,worldFacade:q.func,worldProps:q.object,canvasStyle:q.object,className:q.string,continuousRender:q.bool,onCanvasRef:q.func,stats:q.bool,cursor:q.string};u.Facade=k;u.ListFacade=ja;u.ParentFacade=M;u.PointerEventTarget=N;u.ReactCanvasBase= | ||
E;u.WorldBaseFacade=x;u.utils=I;Object.defineProperty(u,"__esModule",{value:!0})}); | ||
'use strict';(function(u,A){"object"===typeof exports&&"undefined"!==typeof module?A(exports,require("troika-animation"),require("react"),require("prop-types")):"function"===typeof define&&define.amd?define(["exports","troika-animation","react","prop-types"],A):(u=u||self,A(u.troika_core={},u.troika_animation,u.React,u.PropTypes))})(this,function(u,A,h,p){function P(){for(var c=arguments,a=arguments[0],e=1,b=arguments.length;e<b;e++){var d=c[e];if(d)for(var k in d)d.hasOwnProperty(k)&&(a[k]=d[k])}return a} | ||
function Q(){for(var c=arguments,a=arguments[0],e=1,b=arguments.length;e<b;e++){var d=c[e];if(d)for(var k in d)d.hasOwnProperty(k)&&!a.hasOwnProperty(k)&&(a[k]=d[k])}return a}function R(c,a){if(a)for(var e in a)a.hasOwnProperty(e)&&(c[e]&&"object"===typeof c[e]&&"object"===typeof a[e]?R(c[e],a[e]):c[e]=a[e])}function F(c,a){var e=new WeakMap;return function(b){var d=e.get(b);d||(d=a(b),e.set(b,d));return d}}function S(c){return(c=c.$$typeof)&&c.toString&&"Symbol(react.element)"===c.toString()||!1} | ||
function ca(c,a){return"paused"===c?void 0:Infinity===a?"Infinity":a}function da(c,a){return c.time-a.time}function G(c){return"onDoubleClick"===c?"dblclick":c.replace(/^on/,"").toLowerCase()}function ea(){function c(b,d,e,a){try{b.call(d,e,a)}catch(f){console.error(f)}}var a=this,e=Object.create(null);this.addListenerForFacade=function(b,d,a){d=e[d]||(e[d]={count:0,byFacadeId:Object.create(null)});b=b.$facadeId;var c=d.byFacadeId[b];c?Array.isArray(c)?-1===c.indexOf(a)&&(d.count++,c.push(a)):c!== | ||
a&&(d.count++,d.byFacadeId[b]=[c,a]):(d.count++,d.byFacadeId[b]=a)};this.removeListenerForFacade=function(b,d,a){d=e[d];b=b.$facadeId;var c=d&&d.byFacadeId[b];c===a?(d.count--,delete d.byFacadeId[b]):Array.isArray(c)&&(a=c.indexOf(a),-1<a&&(d.count--,1===c.length?delete d.byFacadeId[b]:c.splice(a,1)))};this.removeAllListenersForFacade=function(b){b=b.$facadeId;for(var d in e){var a=e[d].byFacadeId[b];a&&(e[d].count-=Array.isArray(a)?a.length:1,delete e[d].byFacadeId[b])}};this.hasFacadeListenersOfType= | ||
function(b,d){return e[d]?!!e[d].byFacadeId[b.$facadeId]:!1};this.hasAnyListenersOfType=function(b){return e[b]?0<e[b].count:!1};this.findBubblingEventTarget=function(b,d){for(;b;){if(a.hasFacadeListenersOfType(b,d))return b;b=b.parent}return null};this.forEachFacadeListenerOfType=function(b,d,a,l){d=e[d];b=b.$facadeId;if(d=d&&d.byFacadeId[b])if(Array.isArray(d))for(var k=0;k<d.length;k++)c(a,l,d[k],b);else c(a,l,d,b)};this.forEachListenerOfType=function(b,d,a){if((b=e[b])&&0<b.count)for(var l in b.byFacadeId){var k= | ||
b.byFacadeId[l];if(Array.isArray(k))for(var g=0;g<k.length;g++)c(d,a,k[g],l);else c(d,a,k,l)}};this.dispatchEventOnFacade=function(b,d){function e(b){b.call(c,d)}var c=b;for(d.target=b;c&&!d.propagationStopped;)if(d.currentTarget=c,a.forEachFacadeListenerOfType(c,d.type,e,null),d.bubbles)c=c.parent;else break}}function H(c){return"touchend"===c.type||"touchcancel"===c.type}function fa(c){c.stopPropagation();c.preventDefault()}h=h&&h.hasOwnProperty("default")?h["default"]:h;p=p&&p.hasOwnProperty("default")? | ||
p["default"]:p;var B=Object.assign||P,J=function(){var c=new WeakMap,a=0;return function(e){var b=c.get(e);b||c.set(e,b="$id"+ ++a);return b}}();J=Object.freeze({__proto__:null,assign:B,_assign:P,assignIf:Q,assignDeep:R,forOwn:function(c,a,e){for(var b in c)c.hasOwnProperty(b)&&a.call(e,c[b],b,c)},getIdForObject:J,createClassExtender:F,isReactElement:S});var q=function(c){this.$facadeId="facade"+ha++;this.parent=c};q.prototype.afterUpdate=function(){var c=this.ref;c!==this._lastRef&&("function"=== | ||
typeof this._lastRef&&this._lastRef.call(null,null),"function"===typeof c?(c.call(null,this),this._lastRef=c):this._lastRef=null)};q.prototype.notifyWorld=function(c,a){if(this.parent)this.parent.onNotifyWorld(this,c,a)};q.prototype.onNotifyWorld=function(c,a,e){var b=this._notifiableParent;if(b)b.onNotifyWorld.call(b,c,a,e);else{b=this.parent;for(var d=q.prototype.onNotifyWorld;b;){if(b.onNotifyWorld!==d){this._notifiableParent=b;b.onNotifyWorld(c,a,e);break}b=b.parent}}};q.prototype.traverse=function(c){c(this)}; | ||
q.prototype.forEachChild=function(c){};q.prototype.addEventListener=function(c,a){this.notifyWorld("addEventListener",{type:c,handler:a})};q.prototype.removeEventListener=function(c,a){this.notifyWorld("removeEventListener",{type:c,handler:a})};q.prototype.dispatchEvent=function(c){this.notifyWorld("dispatchEvent",c)};q.prototype.destructor=function(){this.parent&&this.notifyWorld("removeAllEventListeners");"function"===typeof this.ref&&this.ref.call(null,null);this.parent=this._notifiableParent= | ||
null};B(q.prototype,{ref:null,_lastRef:null,_notifiableParent:null});var ha=0,ia={key:1,facade:1,transition:1,animation:1};q.isSpecialDescriptorProperty=function(c){return ia.hasOwnProperty(c)};q.defineEventProperty=function(c,a,e){var b=a+"\u27a4handler";Object.defineProperty(c.prototype,a,{get:function(){return this[b]},set:function(d){var a=this[b];(d||null)!==(a||null)&&("function"===typeof a&&this.removeEventListener(e,a),"function"===typeof d&&this.addEventListener(e,d),this[b]=d)}})};var T= | ||
[null],U=F("animatable",function(c){function a(b,d){if(!e.prototype.hasOwnProperty(b)){for(var a=b+"\u27a4anim:actualValue",l=b+"\u27a4anim:actuallySet",f=b+"\u27a4anim:hasBeenSet",g=b+"\u27a4anim:tween",m,I,v=c.prototype;v;){var K=Object.getOwnPropertyDescriptor(v,b);if(K){I=K.set;m=K.get;if(I&&!m||m&&!I)throw Error("Animatable: property "+b+" has a custom "+(I?"setter":"getter")+" but no "+(I?"getter":"setter")+". Animatable properties must have both.");break}v=Object.getPrototypeOf(v)}var n=I? | ||
function(b){I.call(this,b);this[f]||(this[f]=!0)}:function(b){this[a]=b;this[f]||(this[f]=!0)};Object.defineProperty(e.prototype,l,{value:n});Object.defineProperty(e.prototype,b,{get:function(){return m?m.call(this):this[f]?this[a]:c.prototype[b]},set:function(d){if(!this.animation$animatingProps||!this.animation$animatingProps[b]){var a=this.animation$runner,c=this.transition;if(c&&c[b]&&this[f]&&c.hasOwnProperty(b)){c=c[b];var e=this[g],l=!1;e?d!==e.toValue&&(a.stop(e),l=!0):d!==this[b]&&(l=!0); | ||
l&&(e=this[g]=new A.Tween(n.bind(this),this[b],d,c.duration||750,c.delay||0,c.easing||"easeOutCubic",1,"forward",c.interpolate||"number"),a.start(e))}else n.call(this,d),(d=this[g])&&a.stop(d),this[g]=null}}})}d.hasOwnProperty(b)&&(d[b+"\u27a4anim:actualValue"]=d[b],d[b+"\u27a4anim:hasBeenSet"]=!0,delete d[b])}var e=function(b){function d(){for(var d=this,a=[],c=arguments.length;c--;)a[c]=arguments[c];b.apply(this,a);this.animation$runner=new A.Runner;this.animation$runner.onTick=function(){d.afterUpdate(); | ||
d.notifyWorld("needsRender")}}b&&(d.__proto__=b);d.prototype=Object.create(b&&b.prototype);d.prototype.constructor=d;var c={transition:{configurable:!0},animation:{configurable:!0}};c.transition.set=function(b){if(b)for(var d in b)b.hasOwnProperty(d)&&a(d,this);this.transition$descriptor=b};c.transition.get=function(){return this.transition$descriptor};c.animation.set=function(b){if(this.animation$descriptor!==b){this.animation$descriptor=b;var d=this.animation$tweens||null,c=this.animation$tweens= | ||
b?Object.create(null):null,e=this.animation$runner,l=!1;b&&!Array.isArray(b)&&(T[0]=b,b=T);if(b)for(var k=0,K=b.length;k<K;k++){var n=b[k];if(n){var t=JSON.stringify(n,ca);if(d&&t in d){var r=d[t];n.paused?e.pause(r):e.start(r);c[t]=r}else{l=0;var h=750,p="linear",q=1;r=[];var u="forward",w;for(w in n)if(n.hasOwnProperty(w))switch(w){case "duration":h=n[w];break;case "delay":l=n[w];break;case "easing":p=n[w];break;case "iterations":q=n[w];break;case "direction":u=n[w];break;default:var z="from"=== | ||
w?0:"to"===w?100:parseFloat(w);if(!isNaN(z)&&0<=z&&100>=z){r.push({time:z/100,props:n[w]});for(var x in n[w])n[w].hasOwnProperty(x)&&(a(x,this),z=x+"\u27a4anim:tween",this[z]&&(e.stop(this[z]),this[z]=null))}}if(r.length){r.sort(da);0<r[0].time&&r.unshift(Q({time:0},r[0]));z=[];for(var y=1,B=r.length;y<B;y++){var E=r[y],F=E.props,C;for(C in F)if(F.hasOwnProperty(C)){for(var D=null,G=y;G--;)if(C in r[G].props){D=r[G];break}D&&(D=new A.Tween(this[C+"\u27a4anim:actuallySet"].bind(this),D.props[C],F[C], | ||
(E.time-D.time)*h,D.time*h,"linear",1,"forward",n.interpolate&&n.interpolate[C]||"number"),D.$$property=C,z.push(D))}}t=c[t]=new A.MultiTween(z,h,l,p,q,u);n.paused||e.start(t);if(0===l){n=r[0].props;for(var H in n)if(n.hasOwnProperty(H))this[H+"\u27a4anim:actuallySet"](n[H])}}l=!0}}}if(d)for(var L in d)c&&c[L]||(b=d[L],b.gotoEnd(),e.stop(b),l=!0);if(l)if(c){d=this.animation$animatingProps=Object.create(null);for(var J in c)for(e=c[J].tweens,L=e.length;L--;)d[e[L].$$property]=!0}else this.animation$animatingProps= | ||
null}};c.animation.get=function(){return this.animation$descriptor};d.prototype.destructor=function(){var d=this,c=this.animation$runner;if(this.exitAnimation&&!this.parent.isDestroying){c.stopAll();this.animation=this.exitAnimation;this.exitAnimation=this.transition=null;var a=c.onTick;c.onTick=function(){d.parent&&!d.parent.isDestroying?a():(c.onDone=null,d.destructor())};c.onDone=function(){d.notifyWorld("needsRender");d.destructor()}}else c.destructor(),b.prototype.destructor.call(this)};Object.defineProperties(d.prototype, | ||
c);return d}(c);return e}),V=F("pointerStates",function(c){function a(b,d){var a=b+"\u27a4pntr:hasBeenSet";d[a]||(d[b+"\u27a4pntr:baseValue"]=d[b],delete d[b],d[a]=!0);if(!m.prototype.hasOwnProperty(b)){g[b]=1;var e=b+"\u27a4pntr:baseValue",k=b+"\u27a4pntr:appliedValue";Object.defineProperty(m.prototype,b,{get:function(){a:{var d=c.prototype;if(b in d)for(;d;){var a=Object.getOwnPropertyDescriptor(d,b);if(a&&a.get){d=a.get;break a}d=Object.getPrototypeOf(d)}d=null}return d?d.call(this):k in this? | ||
this[k]:this[e]},set:function(b){this[e]=b}})}}function e(b,d,a){a:{var e=c.prototype;if(d in e)for(;e;){var k=Object.getOwnPropertyDescriptor(e,d);if(k&&k.set){e=k.set;break a}e=Object.getPrototypeOf(e)}e=null}e?e.call(b,a):b[d+"\u27a4pntr:appliedValue"]=a}function b(b){b.currentTarget["\u27a4pntr:isHovering"]=!0;f(b)}function d(b){b.currentTarget["\u27a4pntr:isHovering"]=b.currentTarget["\u27a4pntr:isActive"]=!1;f(b)}function k(b){b.currentTarget["\u27a4pntr:isActive"]=!0;f(b)}function l(b){b.currentTarget["\u27a4pntr:isActive"]= | ||
!1;f(b)}function f(b){b=b.currentTarget;for(var d=b.parent;d&&d.shouldUpdateChildren();)d.isPointerStateAware&&(b=d),d=d.parent;b.afterUpdate();b.notifyWorld("needsRender")}var g=Object.create(null),m=function(c){function f(a){c.call(this,a);this.addEventListener("mouseover",b);this.addEventListener("mouseout",d);this.addEventListener("mousedown",k);this.addEventListener("mouseup",l)}c&&(f.__proto__=c);f.prototype=Object.create(c&&c.prototype);f.prototype.constructor=f;f.prototype.afterUpdate=function(){this._applyPointerStates(); | ||
c.prototype.afterUpdate.call(this)};f.prototype._applyPointerStates=function(){var b=this.pointerStates,d=b&&this["\u27a4pntr:isHovering"]&&b.hover||null,c=b&&this["\u27a4pntr:isActive"]&&b.active||null;b=this["\u27a4pntr:lastAppliedValues"]||g;if(d=this["\u27a4pntr:lastAppliedValues"]=d||c?B(Object.create(null),d,c):null)for(var k in d)a(k,this),e(this,k,d[k]);if(b)for(var l in b)d&&l in d||e(this,l,this[l+"\u27a4pntr:baseValue"])};return f}(c);Object.defineProperty(m.prototype,"isPointerStateAware", | ||
{value:!0});return m}),ja=function(c){function a(a){c.call(this,a);this._orderedItemKeys=[]}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.afterUpdate=function(){var a=this.data,b=this.template,d=a&&a.length&&Array.isArray(a);if("production"!==process.env.NODE_ENV){if(a&&!Array.isArray(a))throw Error('ListFacade "data" must be an array.');if(!b||"object"!==typeof b)throw Error('ListFacade "template" must be an object.');if(!b||"function"!==typeof b.key)throw Error('ListFacade template must define a "key" function.'); | ||
if(!b||"function"!==typeof b.facade)throw Error('ListFacade template must define a "facade".');}if(this.shouldUpdateChildren()){var k=this._itemsDict||null,l=this._itemsDict=d?Object.create(null):null,f=this._orderedItemKeys;if(d){f.length=a.length;d=0;for(var g=a.length;d<g;d++){var m=a[d],h=b.key(m,d,a),v=b.facade;if("production"!==process.env.NODE_ENV){if(null==h)throw Error('ListFacade template "key" function must return a key.');l[h]&&console.warn("Duplicate key in list: "+h)}for(;l[h];)h+="|dupe"; | ||
var p="function"===typeof b.transition?b.transition(m,d,a):b.transition,n="function"===typeof b.animation?b.animation(m,d,a):b.animation,t="function"===typeof b.exitAnimation?b.exitAnimation(m,d,a):b.exitAnimation;if(p||n||t)v=U(v);t=b.pointerStates;if("function"===t?t(m,d,a):t)v=V(v);(t=k&&k[h])&&t.constructor===v?v=t:(t&&t.destructor(),v=new v(this));v.transition=p;v.animation=n;for(var r in b)b.hasOwnProperty(r)&&!c.isSpecialDescriptorProperty(r)&&(v[r]="function"===typeof b[r]?b[r](m,d,a):b[r]); | ||
v.afterUpdate();l[h]=v;f[d]=h}}if(k)for(var q in k)l&&l[q]||k[q].destructor()}c.prototype.afterUpdate.call(this)};a.prototype.shouldUpdateChildren=function(){return!0};a.prototype.traverse=function(a,b){a.call(b,this);for(var d=this._orderedItemKeys,c=this._itemsDict,e=0,f=d.length;e<f;e++)c[d[e]].traverse(a,b)};a.prototype.forEachChild=function(a,b){for(var d=this._orderedItemKeys,c=this._itemsDict,e=0,f=d.length;e<f;e++)a.call(b,c[d[e]],d[e])};a.prototype.destructor=function(){this.isDestroying= | ||
!0;var a=this._itemsDict;if(a)for(var b in a)a[b].destructor();c.prototype.destructor.call(this)};return a}(q),W=[null],M=function(c){function a(a){c.call(this,a);this.children=null;this._orderedChildKeys=[]}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.afterUpdate=function(){this.shouldUpdateChildren()&&this.updateChildren(this.children);c.prototype.afterUpdate.call(this)};a.prototype.shouldUpdateChildren=function(){return!0};a.prototype.updateChildren= | ||
function(a){var b=this._childrenDict||null,d=this._childrenDict=null,e=this._orderedChildKeys;e.length=0;if(a){Array.isArray(a)||(W[0]=a,a=W);for(var l=0,f=a.length;l<f;l++){var g=a[l];if(g){d||(d=this._childrenDict=Object.create(null));var m=S(g),h=m?g.props:g;m=m?g.type:g.facade;g=g.key;if(!g){var p=0;do g="auto:"+m.name+":"+p++;while(d[g])}if("production"!==process.env.NODE_ENV&&"function"!==typeof m)throw Error('All scene objects must have a "facade" property pointing to a class/constructor'); | ||
if(d[g])for(console.warn("Duplicate key in children: "+g);d[g];)g+="|dupe";p=h.transition;var q=h.animation;if(p||q||h.exitAnimation)m=U(m);h.pointerStates&&(m=V(m));var n=b&&b[g];n&&n.constructor===m?m=n:(n&&n.destructor(),m=new m(this));m.transition=p;m.animation=q;for(var t in h)h.hasOwnProperty(t)&&!c.isSpecialDescriptorProperty(t)&&(m[t]=h[t]);d[g]=m;e.push(g);m.afterUpdate()}}}if(b)for(var r in b)d&&d[r]||b[r].destructor()};a.prototype.getChildByKey=function(a){var b=this._childrenDict;return b&& | ||
b[a]||null};a.prototype.traverse=function(a,b){a.call(b,this);for(var d=this._orderedChildKeys,c=this._childrenDict,e=0,f=d.length;e<f;e++)c[d[e]].traverse(a,b)};a.prototype.forEachChild=function(a,b){for(var d=this._orderedChildKeys,c=this._childrenDict,e=0,f=d.length;e<f;e++)a.call(b,c[d[e]],d[e])};a.prototype.destructor=function(){this.isDestroying=!0;var a=this._childrenDict;if(a)for(var b in a)a[b].destructor();c.prototype.destructor.call(this)};return a}(q),x="onMouseOver onMouseOut onMouseMove onDragStart onDrag onDragEnter onDragOver onDragLeave".split(" "), | ||
E="onMouseDown onMouseUp onClick onDoubleClick onDrop onDragEnd onWheel".split(" "),X=E.map(G),Y=x.map(G);x=x.concat(E);var Z=Y.concat(X),N=function(c){function a(){c.apply(this,arguments)}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.interceptsPointerEvents=function(a){if(!1===this.pointerEvents)return!1;if(this.pointerEvents)return!0;for(var b=0,d=Z.length;b<d;b++)if(a.hasFacadeListenersOfType(this,Z[b]))return!0};return a}(M);Object.defineProperty(N.prototype, | ||
"isPointerEventTarget",{value:!0});x.forEach(function(c){q.defineEventProperty(N,c,G(c))});var ka={},la=["mousemove","mouseout","touchmove"],ma="mousedown mouseup click dblclick wheel touchstart touchend touchcancel".split(" "),aa=["mouseup","touchend","touchcancel"],na={touchstart:"mousedown",touchend:"mouseup",touchcancel:"mouseup"},oa="clientX clientY screenX screenY pageX pageY".split(" "),y=function(c,a,e,b,d){var k=this,l;for(l in c)"function"!==typeof c[l]&&(this[l]=c[l]);this.target=e;this.relatedTarget= | ||
b;this.type=a;this.nativeEvent=c;B(this,d);if(c.touches){var f=H(c)?c.changedTouches:c.touches;1===f.length&&oa.forEach(function(b){k[b]=f[0][b]})}};y.prototype.preventDefault=function(){this.defaultPrevented=!0;this.nativeEvent.preventDefault()};y.prototype.stopPropagation=function(){this.propagationStopped=!0;this.nativeEvent.stopPropagation()};x=function(c){function a(b){c.call(this,null);this.width=this.height=1;this._element=b;this._htmlOverlays=Object.create(null);this.eventRegistry=new ea; | ||
this._onPointerMotionEvent=this._onPointerMotionEvent.bind(this);this._onPointerActionEvent=this._onPointerActionEvent.bind(this);this._onDropEvent=this._onDropEvent.bind(this);this._togglePointerListeners(!0)}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;var e={renderingScheduler:{configurable:!0}};a.prototype.afterUpdate=function(){this._queueRender();c.prototype.afterUpdate.call(this)};a.prototype.onNotifyWorld=function(b,a,c){(a=this._notifyWorldHandlers[a])&& | ||
a.call(this,b,c)};a.prototype._isContinuousRender=function(){return this.continuousRender};e.renderingScheduler.set=function(b){b=b||window;if(b!==this.renderingScheduler){var a=this._nextFrameTimer;a&&(this.renderingScheduler.cancelAnimationFrame(a),this._nextFrameTimer=null);this._renderingScheduler=b}};e.renderingScheduler.get=function(){return this._renderingScheduler||window};a.prototype._queueRender=function(){var b=this;if(!this._nextFrameTimer){var a=this._nextFrameHandler||(this._nextFrameHandler= | ||
function(){for(var a=[],d=arguments.length;d--;)a[d]=arguments[d];d=b.onStatsUpdate;var c=b.onBeforeRender,e=b.onAfterRender,h=d&&Date.now();c&&c(b);b.doRender.apply(b,a);d&&(a=Date.now(),d({"Render CPU Time (ms)":a-h,"Time Between Frames (ms)":b._lastFrameTime?a-b._lastFrameTime:"?",FPS:b._lastFrameTime?Math.round(1E3/(a-b._lastFrameTime)):"?"}),b._lastFrameTime=a);b._doRenderHtmlItems();e&&e(b);b._nextFrameTimer=null;b._isContinuousRender()&&b._queueRender()});this._nextFrameTimer=this.renderingScheduler.requestAnimationFrame(a)}}; | ||
a.prototype.doRender=function(){};a.prototype.getFacadeUserSpaceXYZ=function(b){};a.prototype._doRenderHtmlItems=function(){if(this.renderHtmlItems){var b=[],a=this._htmlOverlays,c;for(c in a){var e=a[c],f=this.getFacadeUserSpaceXYZ(e);0<=f.z&&(f.key=e.$facadeId,f.html=e.html,f.exact=e.exact,b.push(f))}this.renderHtmlItems(b)}};a.prototype._normalizePointerEvent=function(b){};a.prototype._onPointerMotionEvent=function(b){this._normalizePointerEvent(b);var a=this._getPointerEventState(b);if(Y.some(this.eventRegistry.hasAnyListenersOfType)){var c= | ||
"mouseout"===b.type||H(b)?null:this._findHoverTarget(b),e=a.hoveredFacade,f=a.hoveredFacade=c&&c.facade,g=a.dragInfo;g&&(g.dragStartFired||(this._firePointerEvent("dragstart",g.dragStartEvent,g.draggedFacade,null,c),g.dragStartFired=!0),this._firePointerEvent("drag",b,g.draggedFacade,null,c));f!==e&&(e&&(this._firePointerEvent("mouseout",b,e,f,c),g&&this._firePointerEvent("dragleave",b,e,f,c)),f&&(this._firePointerEvent("mouseover",b,f,e,c),g&&this._firePointerEvent("dragenter",b,f,e,c)));f&&(this._firePointerEvent("mousemove", | ||
b,f,null,c),g&&this._firePointerEvent("dragover",b,f,null,c))}(c=a.tapInfo)&&"touchmove"===b.type&&(b=b.changedTouches[0])&&10<Math.sqrt(Math.pow(b.clientX-c.x,2)+Math.pow(b.clientY-c.y,2))&&(a.tapInfo=null)};a.prototype._onPointerActionEvent=function(b){this._normalizePointerEvent(b);-1<aa.indexOf(b.type)&&this._onDropEvent(b);"touchstart"===b.type&&(1===b.touches.length&&this._onPointerMotionEvent(b),this._enableContextMenu(!1));var a=this.eventRegistry;if(a.hasAnyListenersOfType("dragstart")|| | ||
X.some(a.hasAnyListenersOfType)){var c=this._findHoverTarget(b),e=c&&c.facade;if(e){var f=this._getPointerEventState(b);this._firePointerEvent(na[b.type]||b.type,b,e,null,c);if(a.findBubblingEventTarget(e,"click")||a.findBubblingEventTarget(e,"dblclick")){var g=f.tapInfo;"touchstart"===b.type&&1===b.touches.length?f.tapInfo={facade:e,x:b.touches[0].clientX,y:b.touches[0].clientY,startTime:Date.now(),isDblClick:g&&300>Date.now()-g.startTime}:g&&g.facade===e&&"touchend"===b.type&&0===b.touches.length&& | ||
1===b.changedTouches.length&&300>Date.now()-g.startTime&&(this._firePointerEvent("click",b,e,null,c),g.isDblClick&&this._firePointerEvent("dblclick",b,e,null,c))}if("mousedown"===b.type||"touchstart"===b.type)if(a=a.findBubblingEventTarget(e,"dragstart"))c=new y(b,"dragstart",a,null,{intersection:c}),f.dragInfo={draggedFacade:a,dragStartFired:!1,dragStartEvent:c},this._toggleDropListeners(!0)}b.preventDefault()}H(b)&&(1===b.changedTouches.length&&this._onPointerMotionEvent(b),this._enableContextMenu(!0))}; | ||
a.prototype._onDropEvent=function(b){var a=this._getPointerEventState(b),c=a.dragInfo;if(c){this._normalizePointerEvent(b);var e=this._findHoverTarget(b),f=e&&e.facade;f&&this._firePointerEvent("drop",b,f,null,e);this._firePointerEvent("dragend",b,c.draggedFacade,null,e);this._toggleDropListeners(!1);a.dragInfo=null}};a.prototype._firePointerEvent=function(b,a,c,e,f){b=a instanceof y?a:new y(a,b,c,e,{bubbles:!0,intersection:f});this.eventRegistry.dispatchEventOnFacade(c,b)};a.prototype._getPointerEventState= | ||
function(b){var a=this._pointerEventStates||(this._pointerEventStates=new WeakMap);b=b.eventSource||ka;var c=a.get(b);c||a.set(b,c={});return c};a.prototype._toggleDropListeners=function(b){var a=this;aa.forEach(function(c){document[(b?"add":"remove")+"EventListener"](c,a._onDropEvent,!0)})};a.prototype._togglePointerListeners=function(b){var a=this,c=this._element;if(c&&b!==this._pointerListenersAttached){var e=(b?"add":"remove")+"EventListener";la.forEach(function(b){c[e](b,a._onPointerMotionEvent, | ||
!1)});ma.forEach(function(b){c[e](b,a._onPointerActionEvent,!1)});this._pointerListenersAttached=b}};a.prototype._enableContextMenu=function(b){var a=this._element;if(a)a[(b?"remove":"add")+"EventListener"]("contextmenu",fa,!0)};a.prototype.getFacadesAtEvent=function(b,a){throw Error("getFacadesAtEvent: no impl");};a.prototype._findHoverTarget=function(b){var a=this;if(b.touches&&1<b.touches.length)return null;if(b=this.getFacadesAtEvent(b,function(b){return b.isPointerEventTarget&&b.interceptsPointerEvents(a.eventRegistry)})){for(var c= | ||
b[0],e=1;e<b.length;e++)if(b[e].distance<c.distance||b[e].distance===c.distance&&(b[e].distanceBias||0)<(c.distanceBias||0))c=b[e];return c}return null};a.prototype.destructor=function(){this._nextFrameTimer&&this.renderingScheduler.cancelAnimationFrame(this._nextFrameTimer);this._togglePointerListeners(!1);this._toggleDropListeners(!1);c.prototype.destructor.call(this)};Object.defineProperties(a.prototype,e);return a}(M);Object.defineProperty(x.prototype,"isWorld",{value:!0});x.prototype._notifyWorldHandlers= | ||
{needsRender:function(){this._queueRender()},addEventListener:function(c,a){this.eventRegistry.addListenerForFacade(c,a.type,a.handler)},removeEventListener:function(c,a){this.eventRegistry.removeListenerForFacade(c,a.type,a.handler)},removeAllEventListeners:function(c){this.eventRegistry.removeAllListenersForFacade(c)},dispatchEvent:function(c,a){a instanceof y||(a=new y(a,a.type,a.target,a.relatedTarget));this.eventRegistry.dispatchEventOnFacade(c,a)},addHtmlOverlay:function(c){this._htmlOverlays[c.$facadeId]= | ||
c},removeHtmlOverlay:function(c){delete this._htmlOverlays[c.$facadeId]},statsUpdate:function(c,a){(c=this.onStatsUpdate)&&c(a)}};var pa={position:"absolute",top:0,right:0,bottom:0,left:0,pointerEvents:"none",transformStyle:"preserve-3d"},O=function(c){function a(){c.apply(this,arguments)}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.shouldComponentUpdate=function(a){return a.html!==this.props.html||!0===(a.html.props&&a.html.props.shouldUpdateOnMove)}; | ||
a.prototype.render=function(){var a=this.props.html;return"string"===typeof a?h.createElement("span",null,a):h.cloneElement(a)};return a}(h.Component);O.displayName="Canvas3D.HtmlOverlayContent";O.propTypes={html:p.node};var ba=function(c){function a(a){c.call(this,a);this.setItems=this.setItems.bind(this);this.state={items:null}}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.shouldComponentUpdate=function(a,b){a=this.state;return b.items&&b.items.length|| | ||
a.items&&a.items.length};a.prototype.setItems=function(a){var b=this.state.items;(a&&a.length||b&&b.length)&&this.setState({items:a||null})};a.prototype.render=function(){var a=this.state.items,b=Math.round;return a&&a.length?h.createElement("div",{className:"troika_html_overlay",style:pa},a.map(function(a){var c=a.key,d=a.html,e=a.x,g=a.y,m=a.z;a.exact||(e=b(e),g=b(g));return h.createElement("div",{key:c,style:{position:"absolute",transform:"translate3d("+e+"px, "+g+"px, "+-m+"px)"}},h.createElement(O, | ||
{html:d}))})):null};return a}(h.Component);ba.displayName="Canvas3D.HtmlOverlay";var qa={position:"absolute",top:0,right:0,background:"rgba(0,0,0,.5)",font:"11px sans-serif",padding:10},ra=function(c){function a(a){c.call(this,a);this.state={stats:{}}}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.setStats=function(a){this.setState({stats:a})};a.prototype.render=function(){var a=this.state.stats;return h.createElement("div",{style:qa},Object.keys(a).sort().map(function(b){return h.createElement("div", | ||
{key:b},b,": ",a[b])}))};return a}(h.Component),sa={width:"100%",height:"100%"};E=function(c){function a(a){c.call(this,a);this._stats={};this.updateStats=this.updateStats.bind(this);this.renderHtmlItems=this.renderHtmlItems.bind(this);this._bindHtmlOverlayRef=this._bindHtmlOverlayRef.bind(this);this._bindCanvasRef=this._bindCanvasRef.bind(this);this._bindStatsRef=this._bindStatsRef.bind(this)}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.componentDidUpdate= | ||
function(){this.updateWorld()};a.prototype.initWorld=function(a){a=new this.props.worldFacade(a);a.renderHtmlItems=this.renderHtmlItems;return a};a.prototype.updateWorld=function(){var a=this._world;if(a){var b=this.props,c=b.stats,h=c&&Date.now();a.width=b.width;a.height=b.height;a.pixelRatio=b.pixelRatio;a.continuousRender=b.continuousRender;a.onStatsUpdate=c?this.updateStats:null;B(a,b.worldProps);a.afterUpdate();c&&this.updateStats({"Last World Update (ms)":Date.now()-h})}};a.prototype.destroyWorld= | ||
function(){this._world&&(this._world.destructor(),delete this._world);clearTimeout(this._statsDelay)};a.prototype.renderHtmlItems=function(a){this._htmlOverlayRef&&this._htmlOverlayRef.setItems(a)};a.prototype.updateStats=function(a){var b=this;this._stats=B({},this._stats,a);this._statsDelay||(this._statsDelay=setTimeout(function(){b._statsDelay=null;var a=b._statsRef;a&&a.setStats(b._stats)},250))};a.prototype._bindHtmlOverlayRef=function(a){this._htmlOverlayRef=a};a.prototype._bindCanvasRef=function(a){if(a)try{this._world= | ||
this.initWorld(a),this.updateWorld()}catch(d){console.warn("Troika."+this.constructor.displayName+": world init failed, using fallback content.",d),this._failedWorldInit=!0,this._world=null,this.forceUpdate()}else this.destroyWorld();var b=this.props.onCanvasRef;b&&b(a)};a.prototype._bindStatsRef=function(a){this._statsRef=a};a.prototype.render=function(){var a=this.props;return h.createElement("div",{className:"troika "+(a.className||""),style:{position:"relative",overflow:"hidden",width:a.width, | ||
height:a.height,cursor:a.cursor,userSelect:"none"}},this._failedWorldInit?this.props.children:h.createElement("canvas",{className:"troika_canvas",ref:this._bindCanvasRef,style:a.canvasStyle||sa}),h.createElement(ba,{ref:this._bindHtmlOverlayRef}),a.stats?h.createElement(ra,{ref:this._bindStatsRef}):null)};return a}(h.Component);E.commonPropTypes={width:p.number.isRequired,height:p.number.isRequired,pixelRatio:p.number,worldFacade:p.func,worldProps:p.object,canvasStyle:p.object,className:p.string, | ||
continuousRender:p.bool,onCanvasRef:p.func,stats:p.bool,cursor:p.string};u.Facade=q;u.ListFacade=ja;u.ParentFacade=M;u.PointerEventTarget=N;u.ReactCanvasBase=E;u.WorldBaseFacade=x;u.utils=J;Object.defineProperty(u,"__esModule",{value:!0})}); |
{ | ||
"name": "troika-core", | ||
"version": "0.15.6", | ||
"version": "0.16.0", | ||
"description": "Troika Core", | ||
@@ -19,3 +19,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"prop-types": "^15.6.2", | ||
"troika-animation": "^0.15.0" | ||
"troika-animation": "^0.16.0" | ||
}, | ||
@@ -26,3 +26,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "13acfe60f037e5156d7b29940ea87c66b3e71ead" | ||
"gitHead": "b17e3967b2166f102cabc6cd4bf46f5a725a8910" | ||
} |
@@ -398,2 +398,3 @@ import { assignIf } from '../utils' | ||
currentInstance[`${ propName }➤anim:actualValue`] = currentInstance[propName] | ||
currentInstance[`${ propName }➤anim:hasBeenSet`] = true | ||
delete currentInstance[propName] | ||
@@ -400,0 +401,0 @@ } |
@@ -80,2 +80,20 @@ /** | ||
this.findBubblingEventTarget = (targetFacade, eventType) => { | ||
while (targetFacade) { | ||
if (this.hasFacadeListenersOfType(targetFacade, eventType)) { | ||
return targetFacade | ||
} | ||
targetFacade = targetFacade.parent | ||
} | ||
return null | ||
} | ||
function tryCall(func, scope, arg1, arg2) { | ||
try { | ||
func.call(scope, arg1, arg2) | ||
} catch(err) { | ||
console.error(err) | ||
} | ||
} | ||
this.forEachFacadeListenerOfType = (facade, type, callback, scope) => { | ||
@@ -88,6 +106,6 @@ const listenersOfType = byEventType[type] | ||
for (let i = 0; i < handlers.length; i++) { | ||
callback.call(scope, handlers[i], facadeId) | ||
tryCall(callback, scope, handlers[i], facadeId) | ||
} | ||
} else { | ||
callback.call(scope, handlers, facadeId) | ||
tryCall(callback, scope, handlers, facadeId) | ||
} | ||
@@ -104,6 +122,6 @@ } | ||
for (let i = 0; i < facadeListeners.length; i++) { | ||
callback.call(scope, facadeListeners[i], facadeId) | ||
tryCall(callback, scope, facadeListeners[i], facadeId) | ||
} | ||
} else { | ||
callback.call(scope, facadeListeners, facadeId) | ||
tryCall(callback, scope, facadeListeners, facadeId) | ||
} | ||
@@ -110,0 +128,0 @@ } |
@@ -43,2 +43,3 @@ import Facade from './Facade' | ||
const orderedChildKeys = this._orderedChildKeys | ||
orderedChildKeys.length = 0 | ||
@@ -52,3 +53,2 @@ if (children) { | ||
let childIndex = 0 | ||
for (let i = 0, len = children.length; i < len; i++) { | ||
@@ -121,9 +121,6 @@ let childDesc = children[i] | ||
} | ||
newDict[key] = newImpl | ||
orderedChildKeys.push(key) | ||
newImpl.afterUpdate() | ||
newDict[key] = newImpl | ||
orderedChildKeys[childIndex++] = key | ||
} | ||
orderedChildKeys.length = childIndex | ||
} else { | ||
orderedChildKeys.length = 0 | ||
} | ||
@@ -130,0 +127,0 @@ |
@@ -124,17 +124,20 @@ import ParentFacade from './ParentFacade' | ||
/** | ||
* @protected Schedule a callback for the next renderable frame. Defaults to browser's | ||
* `requestAnimationFrame` but can be overridden to use different timing strategies such | ||
* as WebVR's device frame rate scheduler. | ||
* @property {{requestAnimationFrame, cancelAnimationFrame}} renderingScheduler | ||
* The object holding `requestAnimationFrame` and `cancelAnimationFrame` scheduling | ||
* functions. Defaults to `window` but can be switched to another implementation, e.g. | ||
* to use an XRSession's custom scheduler. | ||
*/ | ||
_requestRenderFrame(callback) { | ||
return window.requestAnimationFrame(callback) | ||
set renderingScheduler(scheduler) { | ||
scheduler = scheduler || window | ||
if (scheduler !== this.renderingScheduler) { | ||
const activeHandle = this._nextFrameTimer | ||
if (activeHandle) { | ||
this.renderingScheduler.cancelAnimationFrame(activeHandle) | ||
this._nextFrameTimer = null | ||
} | ||
this._renderingScheduler = scheduler | ||
} | ||
} | ||
/** | ||
* @protected Cancel a scheduled callback for the next renderable frame. Defaults to browser's | ||
* `cancelAnimationFrame` but can be overridden to use different timing strategies such | ||
* as WebVR's device frame rate scheduler. | ||
*/ | ||
_cancelAnimationFrame(frameId) { | ||
return window.cancelAnimationFrame(frameId) | ||
get renderingScheduler() { | ||
return this._renderingScheduler || window | ||
} | ||
@@ -145,3 +148,3 @@ | ||
if (!this._nextFrameTimer) { | ||
this._nextFrameTimer = this._requestRenderFrame(this._nextFrameHandler || (this._nextFrameHandler = (...args) => { | ||
const handler = this._nextFrameHandler || (this._nextFrameHandler = (...args) => { | ||
let {onStatsUpdate, onBeforeRender, onAfterRender} = this | ||
@@ -173,3 +176,4 @@ let start = onStatsUpdate && Date.now() | ||
} | ||
})) | ||
}) | ||
this._nextFrameTimer = this.renderingScheduler.requestAnimationFrame(handler) | ||
} | ||
@@ -305,3 +309,3 @@ } | ||
// touchstart/touchend could be start/end of a tap - map to click | ||
if (this._hasEventHandlerInParentTree(facade, 'click') || this._hasEventHandlerInParentTree(facade, 'dblclick')) { | ||
if (eventRegistry.findBubblingEventTarget(facade, 'click') || eventRegistry.findBubblingEventTarget(facade, 'dblclick')) { | ||
let tapInfo = eventState.tapInfo | ||
@@ -331,11 +335,14 @@ if (e.type === 'touchstart' && e.touches.length === 1) { | ||
// mousedown/touchstart could be prepping for drag gesture | ||
if (facade.onDragStart && (e.type === 'mousedown' || e.type === 'touchstart')) { | ||
let dragStartEvent = new SyntheticEvent(e, 'dragstart', facade, null, {intersection: hoverInfo}) | ||
eventState.dragInfo = { | ||
draggedFacade: facade, | ||
dragStartFired: false, | ||
dragStartEvent: dragStartEvent | ||
if (e.type === 'mousedown' || e.type === 'touchstart') { | ||
const dragger = eventRegistry.findBubblingEventTarget(facade, 'dragstart') | ||
if (dragger) { | ||
let dragStartEvent = new SyntheticEvent(e, 'dragstart', dragger, null, {intersection: hoverInfo}) | ||
eventState.dragInfo = { | ||
draggedFacade: dragger, | ||
dragStartFired: false, | ||
dragStartEvent: dragStartEvent | ||
} | ||
// handle release outside canvas | ||
this._toggleDropListeners(true) | ||
} | ||
// handle release outside canvas | ||
this._toggleDropListeners(true) | ||
} | ||
@@ -398,12 +405,2 @@ } | ||
_hasEventHandlerInParentTree(targetFacade, eventType) { | ||
while (targetFacade) { | ||
if (this.eventRegistry.hasFacadeListenersOfType(eventType)) { | ||
return true | ||
} | ||
targetFacade = targetFacade.parent | ||
} | ||
return false | ||
} | ||
_toggleDropListeners(on) { | ||
@@ -477,3 +474,3 @@ dropEventTypes.forEach(type => { | ||
if (this._nextFrameTimer) { | ||
this._cancelAnimationFrame(this._nextFrameTimer) | ||
this.renderingScheduler.cancelAnimationFrame(this._nextFrameTimer) | ||
} | ||
@@ -480,0 +477,0 @@ this._togglePointerListeners(false) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
319669
7403
+ Addedtroika-animation@0.16.0(transitive)
- Removedtroika-animation@0.15.0(transitive)
Updatedtroika-animation@^0.16.0