motion-dom 12.4.10 → 12.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -201,10 +201,10 @@ class NativeAnimationControls {
201
201
  this.cancel();
202
202
  }
203
203
  flatten() {
204
- var _a;
205
- if (!this.animation)
204
+ var _a, _b;
205
+ if (!this.animation || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowFlatten))
206
206
  return;
207
- (_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
207
+ (_b = this.animation.effect) === null || _b === void 0 ? void 0 : _b.updateTiming({ easing: "linear" });
208
208
  }
209
209
  attachTimeline(timeline) {
210
210
  if (this.animation)
@@ -59,10 +59,10 @@ class NativeAnimationControls {
59
59
  this.cancel();
60
60
  }
61
61
  flatten() {
62
- var _a;
63
- if (!this.animation)
62
+ var _a, _b;
63
+ if (!this.animation || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowFlatten))
64
64
  return;
65
- (_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
65
+ (_b = this.animation.effect) === null || _b === void 0 ? void 0 : _b.updateTiming({ easing: "linear" });
66
66
  }
67
67
  attachTimeline(timeline) {
68
68
  if (this.animation)
package/dist/index.d.ts CHANGED
@@ -329,6 +329,7 @@ interface ValueAnimationOptions<V extends string | number = number> extends Valu
329
329
  name?: string;
330
330
  from?: V;
331
331
  isGenerator?: boolean;
332
+ allowFlatten?: boolean;
332
333
  }
333
334
  type GeneratorFactory = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
334
335
  type AnimationGeneratorType = GeneratorFactory | "decay" | "spring" | "keyframes" | "tween" | "inertia";
@@ -201,10 +201,10 @@
201
201
  this.cancel();
202
202
  }
203
203
  flatten() {
204
- var _a;
205
- if (!this.animation)
204
+ var _a, _b;
205
+ if (!this.animation || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowFlatten))
206
206
  return;
207
- (_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
207
+ (_b = this.animation.effect) === null || _b === void 0 ? void 0 : _b.updateTiming({ easing: "linear" });
208
208
  }
209
209
  attachTimeline(timeline) {
210
210
  if (this.animation)
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("motion-utils")):"function"==typeof define&&define.amd?define(["exports","motion-utils"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MotionDom={},t.MotionUtils)}(this,(function(t,e){"use strict";const n=e.memo(()=>void 0!==window.ScrollTimeline);class i{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const i=this.animations.map(i=>n()&&i.attachTimeline?i.attachTimeline(t):"function"==typeof e?e(i):void 0);return()=>{i.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach(e=>e[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function o(t,e){return t?t[e]||t.default||t:void 0}function r(t){let e=0;let n=t.next(e);for(;!n.done&&e<2e4;)e+=50,n=t.next(e);return e>=2e4?1/0:e}function a(t,n=100,i){const o=i({...t,keyframes:[0,n]}),a=Math.min(r(o),2e4);return{type:"keyframes",ease:t=>o.next(a*t).value/n,duration:e.millisecondsToSeconds(a)}}function s(t){return"function"==typeof t}function u(t,e){t.timeline=e,t.onfinish=null}class l{constructor(t){this.animation=t}get duration(){var t,n,i;const o=(null===(n=null===(t=this.animation)||void 0===t?void 0:t.effect)||void 0===n?void 0:n.getComputedTiming().duration)||(null===(i=this.options)||void 0===i?void 0:i.duration)||300;return e.millisecondsToSeconds(Number(o))}get time(){var t;return this.animation?e.millisecondsToSeconds((null===(t=this.animation)||void 0===t?void 0:t.currentTime)||0):0}set time(t){this.animation&&(this.animation.currentTime=e.secondsToMilliseconds(t))}get speed(){return this.animation?this.animation.playbackRate:1}set speed(t){this.animation&&(this.animation.playbackRate=t)}get state(){return this.animation?this.animation.playState:"finished"}get startTime(){return this.animation?this.animation.startTime:null}get finished(){return this.animation?this.animation.finished:Promise.resolve()}play(){this.animation&&this.animation.play()}pause(){this.animation&&this.animation.pause()}stop(){this.animation&&"idle"!==this.state&&"finished"!==this.state&&(this.animation.commitStyles&&this.animation.commitStyles(),this.cancel())}flatten(){var t;this.animation&&(null===(t=this.animation.effect)||void 0===t||t.updateTiming({easing:"linear"}))}attachTimeline(t){return this.animation&&u(this.animation,t),e.noop}complete(){this.animation&&this.animation.finish()}cancel(){try{this.animation&&this.animation.cancel()}catch(t){}}}const c=t=>Array.isArray(t)&&"number"==typeof t[0],d={linearEasing:void 0};function m(t,n){const i=e.memo(t);return()=>{var t;return null!==(t=d[n])&&void 0!==t?t:i()}}const f=m(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),h=(t,n,i=10)=>{let o="";const r=Math.max(Math.round(n/i),2);for(let n=0;n<r;n++)o+=t(e.progress(0,r-1,n))+", ";return`linear(${o.substring(0,o.length-2)})`};const p=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,y={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:p([0,.65,.55,1]),circOut:p([.55,0,1,.45]),backIn:p([.31,.01,.66,-.59]),backOut:p([.33,1.53,.69,.99])};function g(t,e){return t?"function"==typeof t&&f()?h(t,e):c(t)?p(t):Array.isArray(t)?t.map(t=>g(t,e)||y.easeOut):y[t]:void 0}const v={x:!1,y:!1};function T(){return v.x||v.y}function E(t,e,n){var i;if(t instanceof EventTarget)return[t];if("string"==typeof t){let o=document;e&&(o=e.current);const r=null!==(i=null==n?void 0:n[t])&&void 0!==i?i:o.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t)}function w(t,e){const n=E(t),i=new AbortController;return[n,{passive:!0,...e,signal:i.signal},()=>i.abort()]}function A(t){return!("touch"===t.pointerType||T())}function b(t,e){const n=e+"PointerCapture";if(t.target instanceof Element&&n in t.target&&void 0!==t.pointerId)try{t.target[n](t.pointerId)}catch(t){}}const x=(t,e)=>!!e&&(t===e||x(t,e.parentElement)),k=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,L=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const P=new WeakSet;function M(t){return e=>{"Enter"===e.key&&t(e)}}function S(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function O(t){return k(t)&&!T()}function C(t){var n;if(s(t.type)){const n=a(t,100,t.type);t.ease=f()?n.ease:"easeOut",t.duration=e.secondsToMilliseconds(n.duration),t.type="keyframes"}else t.duration=e.secondsToMilliseconds(null!==(n=t.duration)&&void 0!==n?n:.3),t.ease=t.ease||"easeOut"}class I extends l{constructor(t,n,i,o,r){const a=function(t,n,i){var o;const r={},a={fill:"both",easing:"linear",composite:"replace"};a.delay=e.secondsToMilliseconds(null!==(o=i.delay)&&void 0!==o?o:0),C(i),a.duration=i.duration;const{ease:s,times:u}=i;u&&(r.offset=u),r[t]=n;const l=g(s,i.duration);return Array.isArray(l)?r.easing=l:a.easing=l,{keyframes:r,options:a}}(i,o,r);super(t.animate(a.keyframes,{pseudoElement:n,...a.options}))}}function $(t){return"layout"===t?"group":"enter"===t||"new"===t?"new":"exit"===t||"old"===t?"old":"group"}let B={},D=null;const N=(t,e)=>{B[t]=e},R=()=>{D||(D=document.createElement("style"),D.id="motion-view");let t="";for(const e in B){const n=B[e];t+=e+" {\n";for(const[e,i]of Object.entries(n))t+=` ${e}: ${i};\n`;t+="}\n"}D.textContent=t,document.head.appendChild(D),B={}},G=()=>{D&&D.parentElement&&D.parentElement.removeChild(D)};function W(t){const e=t.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);return e?{layer:e[2],type:e[1]}:null}function j(t){var e;const{effect:n}=t;return!!n&&(n.target===document.documentElement&&(null===(e=n.pseudoElement)||void 0===e?void 0:e.startsWith("::view-transition")))}const V=["layout","enter","exit","new","old"];function q(t,n,r){if(!document.startViewTransition)return new Promise(async e=>{await t(),e(new i([]))});(function(t,e){return e.has(t)&&Object.keys(e.get(t)).length>0})("root",r)||N(":root",{"view-transition-name":"none"}),N("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)",{"animation-timing-function":"linear !important"}),R();const a=document.startViewTransition(async()=>{await t()});return a.finished.finally(()=>{G()}),new Promise(t=>{a.ready.then(()=>{var a;const s=document.getAnimations().filter(j),u=[];r.forEach((t,e)=>{for(const i of V){if(!t[i])continue;const{keyframes:r,options:a}=t[i];for(let[t,s]of Object.entries(r)){if(!s)continue;const r={...o(n,t),...o(a,t)},l=$(i);if("opacity"===t&&!Array.isArray(s)){s=["new"===l?0:1,s]}"function"==typeof r.delay&&(r.delay=r.delay(0,1));const c=new I(document.documentElement,`::view-transition-${l}(${e})`,t,s,r);u.push(c)}}});for(const t of s){if("finished"===t.playState)continue;const{effect:i}=t;if(!(i&&i instanceof KeyframeEffect))continue;const{pseudoElement:s}=i;if(!s)continue;const c=W(s);if(!c)continue;const d=r.get(c.layer);if(d)z(d,"enter")&&z(d,"exit")&&i.getKeyframes().some(t=>t.mixBlendMode)?u.push(new l(t)):t.cancel();else{const r="group"===c.type?"layout":"",s={...o(n,r)};C(s);const d=g(s.ease,s.duration);i.updateTiming({delay:e.secondsToMilliseconds(null!==(a=s.delay)&&void 0!==a?a:0),duration:s.duration,easing:d}),u.push(new l(t))}}t(new i(u))})})}function z(t,e){var n;return null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.keyframes.opacity}class U{constructor(t,n={}){this.currentTarget="root",this.targets=new Map,this.notifyReady=e.noop,this.readyPromise=new Promise(t=>{this.notifyReady=t}),queueMicrotask(()=>{q(t,n,this.targets).then(t=>this.notifyReady(t))})}get(t){return this.currentTarget=t,this}layout(t,e){return this.updateTarget("layout",t,e),this}new(t,e){return this.updateTarget("new",t,e),this}old(t,e){return this.updateTarget("old",t,e),this}enter(t,e){return this.updateTarget("enter",t,e),this}exit(t,e){return this.updateTarget("exit",t,e),this}crossfade(t){return this.updateTarget("enter",{opacity:1},t),this.updateTarget("exit",{opacity:0},t),this}updateTarget(t,e,n={}){const{currentTarget:i,targets:o}=this;o.has(i)||o.set(i,{});o.get(i)[t]={keyframes:e,options:n}}then(t,e){return this.readyPromise.then(t,e)}}t.GroupPlaybackControls=class extends i{then(t,e){return Promise.all(this.animations).then(t).catch(e)}},t.NativeAnimationControls=l,t.ViewTransitionBuilder=U,t.attachTimeline=u,t.calcGeneratorDuration=r,t.capturePointer=b,t.createGeneratorEasing=a,t.cubicBezierAsString=p,t.generateLinearEasing=h,t.getValueTransition=o,t.hover=function(t,e,n={}){const[i,o,r]=w(t,n),a=t=>{if(!A(t))return;const{target:n}=t,i=e(n,t);if("function"!=typeof i||!n)return;const r=t=>{A(t)&&(i(t),n.removeEventListener("pointerleave",r))};n.addEventListener("pointerleave",r,o)};return i.forEach(t=>{t.addEventListener("pointerenter",a,o)}),r},t.isBezierDefinition=c,t.isDragActive=T,t.isDragging=v,t.isGenerator=s,t.isNodeOrChild=x,t.isPrimaryPointer=k,t.isWaapiSupportedEasing=function t(e){return Boolean("function"==typeof e&&f()||!e||"string"==typeof e&&(e in y||f())||c(e)||Array.isArray(e)&&e.every(t))},t.mapEasingToNativeEasing=g,t.maxGeneratorDuration=2e4,t.press=function(t,e,n={}){const[i,o,r]=w(t,n),a=t=>{const n=t.currentTarget;if(!n||!O(t)||P.has(n))return;P.add(n),b(t,"set");const i=e(n,t),r=(t,e)=>{n.removeEventListener("pointerup",a),n.removeEventListener("pointercancel",s),b(t,"release"),O(t)&&P.has(n)&&(P.delete(n),"function"==typeof i&&i(t,{success:e}))},a=t=>{const e=!!t.isTrusted&&(i=t,o=n instanceof Element?n.getBoundingClientRect():{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},i.clientX<o.left||i.clientX>o.right||i.clientY<o.top||i.clientY>o.bottom);var i,o;r(t,!e&&(!(n instanceof Element)||x(n,t.target)))},s=t=>{r(t,!1)};n.addEventListener("pointerup",a,o),n.addEventListener("pointercancel",s,o),n.addEventListener("lostpointercapture",s,o)};return i.forEach(t=>{let e=!1;var i;(t=n.useGlobalTarget?window:t)instanceof HTMLElement&&(e=!0,i=t,L.has(i.tagName)||-1!==i.tabIndex||null!==t.getAttribute("tabindex")||(t.tabIndex=0)),t.addEventListener("pointerdown",a,o),e&&t.addEventListener("focus",t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const i=M(()=>{if(P.has(n))return;S(n,"down");const t=M(()=>{S(n,"up")});n.addEventListener("keyup",t,e),n.addEventListener("blur",()=>S(n,"cancel"),e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)})(t,o),o)}),r},t.resolveElements=E,t.setDragLock=function(t){return"x"===t||"y"===t?v[t]?null:(v[t]=!0,()=>{v[t]=!1}):v.x||v.y?null:(v.x=v.y=!0,()=>{v.x=v.y=!1})},t.supportedWaapiEasing=y,t.supportsFlags=d,t.supportsLinearEasing=f,t.supportsScrollTimeline=n,t.view=function(t,e={}){return new U(t,e)}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("motion-utils")):"function"==typeof define&&define.amd?define(["exports","motion-utils"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MotionDom={},t.MotionUtils)}(this,(function(t,e){"use strict";const n=e.memo(()=>void 0!==window.ScrollTimeline);class i{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const i=this.animations.map(i=>n()&&i.attachTimeline?i.attachTimeline(t):"function"==typeof e?e(i):void 0);return()=>{i.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach(e=>e[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function o(t,e){return t?t[e]||t.default||t:void 0}function r(t){let e=0;let n=t.next(e);for(;!n.done&&e<2e4;)e+=50,n=t.next(e);return e>=2e4?1/0:e}function a(t,n=100,i){const o=i({...t,keyframes:[0,n]}),a=Math.min(r(o),2e4);return{type:"keyframes",ease:t=>o.next(a*t).value/n,duration:e.millisecondsToSeconds(a)}}function s(t){return"function"==typeof t}function u(t,e){t.timeline=e,t.onfinish=null}class l{constructor(t){this.animation=t}get duration(){var t,n,i;const o=(null===(n=null===(t=this.animation)||void 0===t?void 0:t.effect)||void 0===n?void 0:n.getComputedTiming().duration)||(null===(i=this.options)||void 0===i?void 0:i.duration)||300;return e.millisecondsToSeconds(Number(o))}get time(){var t;return this.animation?e.millisecondsToSeconds((null===(t=this.animation)||void 0===t?void 0:t.currentTime)||0):0}set time(t){this.animation&&(this.animation.currentTime=e.secondsToMilliseconds(t))}get speed(){return this.animation?this.animation.playbackRate:1}set speed(t){this.animation&&(this.animation.playbackRate=t)}get state(){return this.animation?this.animation.playState:"finished"}get startTime(){return this.animation?this.animation.startTime:null}get finished(){return this.animation?this.animation.finished:Promise.resolve()}play(){this.animation&&this.animation.play()}pause(){this.animation&&this.animation.pause()}stop(){this.animation&&"idle"!==this.state&&"finished"!==this.state&&(this.animation.commitStyles&&this.animation.commitStyles(),this.cancel())}flatten(){var t,e;this.animation&&(null===(t=this.options)||void 0===t?void 0:t.allowFlatten)&&(null===(e=this.animation.effect)||void 0===e||e.updateTiming({easing:"linear"}))}attachTimeline(t){return this.animation&&u(this.animation,t),e.noop}complete(){this.animation&&this.animation.finish()}cancel(){try{this.animation&&this.animation.cancel()}catch(t){}}}const c=t=>Array.isArray(t)&&"number"==typeof t[0],d={linearEasing:void 0};function m(t,n){const i=e.memo(t);return()=>{var t;return null!==(t=d[n])&&void 0!==t?t:i()}}const f=m(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),h=(t,n,i=10)=>{let o="";const r=Math.max(Math.round(n/i),2);for(let n=0;n<r;n++)o+=t(e.progress(0,r-1,n))+", ";return`linear(${o.substring(0,o.length-2)})`};const p=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,y={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:p([0,.65,.55,1]),circOut:p([.55,0,1,.45]),backIn:p([.31,.01,.66,-.59]),backOut:p([.33,1.53,.69,.99])};function g(t,e){return t?"function"==typeof t&&f()?h(t,e):c(t)?p(t):Array.isArray(t)?t.map(t=>g(t,e)||y.easeOut):y[t]:void 0}const v={x:!1,y:!1};function T(){return v.x||v.y}function E(t,e,n){var i;if(t instanceof EventTarget)return[t];if("string"==typeof t){let o=document;e&&(o=e.current);const r=null!==(i=null==n?void 0:n[t])&&void 0!==i?i:o.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t)}function w(t,e){const n=E(t),i=new AbortController;return[n,{passive:!0,...e,signal:i.signal},()=>i.abort()]}function A(t){return!("touch"===t.pointerType||T())}function b(t,e){const n=e+"PointerCapture";if(t.target instanceof Element&&n in t.target&&void 0!==t.pointerId)try{t.target[n](t.pointerId)}catch(t){}}const x=(t,e)=>!!e&&(t===e||x(t,e.parentElement)),k=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,L=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const P=new WeakSet;function M(t){return e=>{"Enter"===e.key&&t(e)}}function S(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function O(t){return k(t)&&!T()}function C(t){var n;if(s(t.type)){const n=a(t,100,t.type);t.ease=f()?n.ease:"easeOut",t.duration=e.secondsToMilliseconds(n.duration),t.type="keyframes"}else t.duration=e.secondsToMilliseconds(null!==(n=t.duration)&&void 0!==n?n:.3),t.ease=t.ease||"easeOut"}class I extends l{constructor(t,n,i,o,r){const a=function(t,n,i){var o;const r={},a={fill:"both",easing:"linear",composite:"replace"};a.delay=e.secondsToMilliseconds(null!==(o=i.delay)&&void 0!==o?o:0),C(i),a.duration=i.duration;const{ease:s,times:u}=i;u&&(r.offset=u),r[t]=n;const l=g(s,i.duration);return Array.isArray(l)?r.easing=l:a.easing=l,{keyframes:r,options:a}}(i,o,r);super(t.animate(a.keyframes,{pseudoElement:n,...a.options}))}}function $(t){return"layout"===t?"group":"enter"===t||"new"===t?"new":"exit"===t||"old"===t?"old":"group"}let B={},D=null;const N=(t,e)=>{B[t]=e},R=()=>{D||(D=document.createElement("style"),D.id="motion-view");let t="";for(const e in B){const n=B[e];t+=e+" {\n";for(const[e,i]of Object.entries(n))t+=` ${e}: ${i};\n`;t+="}\n"}D.textContent=t,document.head.appendChild(D),B={}},G=()=>{D&&D.parentElement&&D.parentElement.removeChild(D)};function W(t){const e=t.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);return e?{layer:e[2],type:e[1]}:null}function j(t){var e;const{effect:n}=t;return!!n&&(n.target===document.documentElement&&(null===(e=n.pseudoElement)||void 0===e?void 0:e.startsWith("::view-transition")))}const V=["layout","enter","exit","new","old"];function q(t,n,r){if(!document.startViewTransition)return new Promise(async e=>{await t(),e(new i([]))});(function(t,e){return e.has(t)&&Object.keys(e.get(t)).length>0})("root",r)||N(":root",{"view-transition-name":"none"}),N("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)",{"animation-timing-function":"linear !important"}),R();const a=document.startViewTransition(async()=>{await t()});return a.finished.finally(()=>{G()}),new Promise(t=>{a.ready.then(()=>{var a;const s=document.getAnimations().filter(j),u=[];r.forEach((t,e)=>{for(const i of V){if(!t[i])continue;const{keyframes:r,options:a}=t[i];for(let[t,s]of Object.entries(r)){if(!s)continue;const r={...o(n,t),...o(a,t)},l=$(i);if("opacity"===t&&!Array.isArray(s)){s=["new"===l?0:1,s]}"function"==typeof r.delay&&(r.delay=r.delay(0,1));const c=new I(document.documentElement,`::view-transition-${l}(${e})`,t,s,r);u.push(c)}}});for(const t of s){if("finished"===t.playState)continue;const{effect:i}=t;if(!(i&&i instanceof KeyframeEffect))continue;const{pseudoElement:s}=i;if(!s)continue;const c=W(s);if(!c)continue;const d=r.get(c.layer);if(d)z(d,"enter")&&z(d,"exit")&&i.getKeyframes().some(t=>t.mixBlendMode)?u.push(new l(t)):t.cancel();else{const r="group"===c.type?"layout":"",s={...o(n,r)};C(s);const d=g(s.ease,s.duration);i.updateTiming({delay:e.secondsToMilliseconds(null!==(a=s.delay)&&void 0!==a?a:0),duration:s.duration,easing:d}),u.push(new l(t))}}t(new i(u))})})}function z(t,e){var n;return null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.keyframes.opacity}class U{constructor(t,n={}){this.currentTarget="root",this.targets=new Map,this.notifyReady=e.noop,this.readyPromise=new Promise(t=>{this.notifyReady=t}),queueMicrotask(()=>{q(t,n,this.targets).then(t=>this.notifyReady(t))})}get(t){return this.currentTarget=t,this}layout(t,e){return this.updateTarget("layout",t,e),this}new(t,e){return this.updateTarget("new",t,e),this}old(t,e){return this.updateTarget("old",t,e),this}enter(t,e){return this.updateTarget("enter",t,e),this}exit(t,e){return this.updateTarget("exit",t,e),this}crossfade(t){return this.updateTarget("enter",{opacity:1},t),this.updateTarget("exit",{opacity:0},t),this}updateTarget(t,e,n={}){const{currentTarget:i,targets:o}=this;o.has(i)||o.set(i,{});o.get(i)[t]={keyframes:e,options:n}}then(t,e){return this.readyPromise.then(t,e)}}t.GroupPlaybackControls=class extends i{then(t,e){return Promise.all(this.animations).then(t).catch(e)}},t.NativeAnimationControls=l,t.ViewTransitionBuilder=U,t.attachTimeline=u,t.calcGeneratorDuration=r,t.capturePointer=b,t.createGeneratorEasing=a,t.cubicBezierAsString=p,t.generateLinearEasing=h,t.getValueTransition=o,t.hover=function(t,e,n={}){const[i,o,r]=w(t,n),a=t=>{if(!A(t))return;const{target:n}=t,i=e(n,t);if("function"!=typeof i||!n)return;const r=t=>{A(t)&&(i(t),n.removeEventListener("pointerleave",r))};n.addEventListener("pointerleave",r,o)};return i.forEach(t=>{t.addEventListener("pointerenter",a,o)}),r},t.isBezierDefinition=c,t.isDragActive=T,t.isDragging=v,t.isGenerator=s,t.isNodeOrChild=x,t.isPrimaryPointer=k,t.isWaapiSupportedEasing=function t(e){return Boolean("function"==typeof e&&f()||!e||"string"==typeof e&&(e in y||f())||c(e)||Array.isArray(e)&&e.every(t))},t.mapEasingToNativeEasing=g,t.maxGeneratorDuration=2e4,t.press=function(t,e,n={}){const[i,o,r]=w(t,n),a=t=>{const n=t.currentTarget;if(!n||!O(t)||P.has(n))return;P.add(n),b(t,"set");const i=e(n,t),r=(t,e)=>{n.removeEventListener("pointerup",a),n.removeEventListener("pointercancel",s),b(t,"release"),O(t)&&P.has(n)&&(P.delete(n),"function"==typeof i&&i(t,{success:e}))},a=t=>{const e=!!t.isTrusted&&(i=t,o=n instanceof Element?n.getBoundingClientRect():{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},i.clientX<o.left||i.clientX>o.right||i.clientY<o.top||i.clientY>o.bottom);var i,o;r(t,!e&&(!(n instanceof Element)||x(n,t.target)))},s=t=>{r(t,!1)};n.addEventListener("pointerup",a,o),n.addEventListener("pointercancel",s,o),n.addEventListener("lostpointercapture",s,o)};return i.forEach(t=>{let e=!1;var i;(t=n.useGlobalTarget?window:t)instanceof HTMLElement&&(e=!0,i=t,L.has(i.tagName)||-1!==i.tabIndex||null!==t.getAttribute("tabindex")||(t.tabIndex=0)),t.addEventListener("pointerdown",a,o),e&&t.addEventListener("focus",t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const i=M(()=>{if(P.has(n))return;S(n,"down");const t=M(()=>{S(n,"up")});n.addEventListener("keyup",t,e),n.addEventListener("blur",()=>S(n,"cancel"),e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)})(t,o),o)}),r},t.resolveElements=E,t.setDragLock=function(t){return"x"===t||"y"===t?v[t]?null:(v[t]=!0,()=>{v[t]=!1}):v.x||v.y?null:(v.x=v.y=!0,()=>{v.x=v.y=!1})},t.supportedWaapiEasing=y,t.supportsFlags=d,t.supportsLinearEasing=f,t.supportsScrollTimeline=n,t.view=function(t,e={}){return new U(t,e)}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-dom",
3
- "version": "12.4.10",
3
+ "version": "12.4.11",
4
4
  "author": "Matt Perry",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/motiondivision/motion",
@@ -23,5 +23,5 @@
23
23
  "build": "yarn clean && tsc -p . && rollup -c",
24
24
  "dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\""
25
25
  },
26
- "gitHead": "18b71d1395e692a13545e85f21bffcbf4a38538b"
26
+ "gitHead": "9316ca820205fedca95a4db2fc0c9f81df77d80c"
27
27
  }