File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -660,12 +660,18 @@ export default function morph (_options) {
660660 animationTo . addEventListener ( 'finish' , cleanup )
661661 animationTo . addEventListener ( 'cancel' , cleanup )
662662
663- cancel = ( ) => {
663+ cancel = abort => {
664664 // we are not in a morph that we can cancel
665665 if ( cancelStatus === true || animationTo === void 0 ) {
666666 return false
667667 }
668668
669+ if ( abort === true ) {
670+ cleanup ( )
671+
672+ return true
673+ }
674+
669675 endElementTo = endElementTo !== true
670676
671677 animationFromClone !== void 0 && animationFromClone . reverse ( )
@@ -855,12 +861,18 @@ export default function morph (_options) {
855861 elTo . addEventListener ( 'animationend' , cleanup )
856862 elTo . addEventListener ( 'animationcancel' , cleanup )
857863
858- cancel = ( ) => {
864+ cancel = abort => {
859865 // we are not in a morph that we can cancel
860866 if ( cancelStatus === true || ! elTo || ! elFromClone || ! elToClone ) {
861867 return false
862868 }
863869
870+ if ( abort === true ) {
871+ cleanup ( )
872+
873+ return true
874+ }
875+
864876 endElementTo = endElementTo !== true
865877
866878 animationDirection = animationDirection === 'normal' ? 'reverse' : 'normal'
@@ -924,5 +936,5 @@ export default function morph (_options) {
924936 // returns:
925937 // false if the cancel cannot be performed (the morph ended already or has not started)
926938 // true else
927- return ( ) => cancel ( )
939+ return abort => cancel ( abort )
928940}
Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ export function throttle<F extends (...args: any[]) => any>(
2727export function uid ( ) : string ;
2828
2929interface MorphOptions {
30- from : Element | string | ( ( ) => Element | undefined ) ;
31- to ?: Element | string | ( ( ) => Element | undefined ) ;
30+ from : Element | string | ( ( ) => Element | null | undefined ) ;
31+ to ?: Element | string | ( ( ) => Element | null | undefined ) ;
3232 onToggle ?: ( ) => void ;
3333 waitFor ?: number | 'transitionend' | Promise < any > ;
3434
@@ -52,4 +52,4 @@ interface MorphOptions {
5252 onReady ?: ( end : 'to' | 'from' ) => void ;
5353}
5454
55- export function morph ( options : MorphOptions ) : ( ) => boolean ;
55+ export function morph ( options : MorphOptions ) : ( abort ?: boolean ) => boolean ;
You can’t perform that action at this time.
0 commit comments