@@ -137,17 +137,16 @@ const updateCssProperties = (element, opts) => {
137
137
* @returns The CSS selector for the animation target(s) or an empty string
138
138
*/
139
139
const getTargetSelector = eventTarget => {
140
- /** @type {HTMLElement|null } triggerBtn */
141
- let triggerBtn = eventTarget ;
142
- while ( triggerBtn && ! triggerBtn . getAttribute ( 'target-selector' ) ) {
140
+ /** @type {HTMLElement|null } trigger */
141
+ let trigger = eventTarget ;
142
+ while ( trigger && ! trigger . getAttribute ( 'target-selector' ) ) {
143
143
/** bubbles up untill the attribute is found */
144
- triggerBtn = triggerBtn . parentElement ;
144
+ trigger = trigger . parentElement ;
145
145
}
146
146
147
- if ( ! triggerBtn )
148
- throw new ReferenceError ( 'target-selector attribute not found' ) ;
147
+ if ( ! trigger ) throw new ReferenceError ( 'target-selector attribute not found' ) ;
149
148
150
- return triggerBtn . getAttribute ( 'target-selector' ) ?? '' ;
149
+ return trigger . getAttribute ( 'target-selector' ) ?? '' ;
151
150
} ;
152
151
153
152
/**
@@ -316,7 +315,7 @@ const animate = (element, action, id, opts = {}) => {
316
315
disable ( element ) ;
317
316
const {
318
317
animType,
319
- triggerBtn ,
318
+ trigger ,
320
319
start,
321
320
complete,
322
321
keepSpace,
@@ -334,7 +333,7 @@ const animate = (element, action, id, opts = {}) => {
334
333
} ) ;
335
334
let parentMeasures , dimension , currentTransition ;
336
335
337
- if ( triggerBtn ) TARGETS_STACK . add ( element , triggerBtn ) ;
336
+ if ( trigger ) TARGETS_STACK . add ( element , trigger ) ;
338
337
339
338
const handleAnimation = {
340
339
begining : {
@@ -388,21 +387,21 @@ const animate = (element, action, id, opts = {}) => {
388
387
} ,
389
388
} ,
390
389
conclude : ( ) => {
391
- if ( triggerBtn && opts . queryIndex === opts . totalTargets - 1 ) {
390
+ if ( trigger && opts . queryIndex === opts . totalTargets - 1 ) {
392
391
opts . staggerDelay
393
- ? CALLBACK_TRACKER . remove ( triggerBtn )
394
- : setTimeout ( ( ) => CALLBACK_TRACKER . remove ( triggerBtn ) , delay ) ;
395
- TARGETS_STACK . get ( triggerBtn ) . forEach ( el => enable ( el ) ) ;
396
- TARGETS_STACK . remove ( triggerBtn ) ;
397
- } else if ( ! triggerBtn ) {
392
+ ? CALLBACK_TRACKER . remove ( trigger )
393
+ : setTimeout ( ( ) => CALLBACK_TRACKER . remove ( trigger ) , delay ) ;
394
+ TARGETS_STACK . get ( trigger ) . forEach ( el => enable ( el ) ) ;
395
+ TARGETS_STACK . remove ( trigger ) ;
396
+ } else if ( ! trigger ) {
398
397
enable ( element ) ;
399
398
}
400
399
} ,
401
400
} ;
402
401
403
402
handleAnimation . begining [ animType ] ( ) ;
404
403
if ( typeof start === 'function' ) {
405
- initCallback ( triggerBtn , start , 'start' ) ;
404
+ initCallback ( trigger , start , 'start' ) ;
406
405
}
407
406
element . classList . add ( CLASS_NAMES [ action ] [ id ] ) ;
408
407
element . classList . remove ( CLASS_NAMES [ OPPOSITE_ACTION [ action ] ] [ id ] ) ;
@@ -411,7 +410,7 @@ const animate = (element, action, id, opts = {}) => {
411
410
setTimeout ( ( ) => {
412
411
handleAnimation . end [ animType ] ( ) ;
413
412
if ( typeof complete === 'function' ) {
414
- initCallback ( triggerBtn , complete , 'complete' ) ;
413
+ initCallback ( trigger , complete , 'complete' ) ;
415
414
}
416
415
handleAnimation . conclude ( ) ;
417
416
} , duration + delay ) ;
@@ -502,13 +501,9 @@ const eventHandler = (el, animationId, opts) => {
502
501
* @see {@link module:globals.MOTION_ANIMS_ID }
503
502
*/
504
503
const init = ( animationId , opts = { } , eventType = 'click' ) => {
505
- const {
506
- triggerBtn = `.${ CLASS_NAMES . triggerBtn } ` ,
507
- targetSelector,
508
- cursor,
509
- } = opts ;
504
+ const { trigger = `.${ CLASS_NAMES . trigger } ` , targetSelector, cursor } = opts ;
510
505
511
- document . querySelectorAll ( triggerBtn ) . forEach ( btn => {
506
+ document . querySelectorAll ( trigger ) . forEach ( btn => {
512
507
btn . classList . add ( CLASS_NAMES . btnCursor ) ;
513
508
if ( typeof cursor === 'string' ) {
514
509
setCssProperty ( btn , 'cursor' , cursor ) ;
0 commit comments