Skip to content

Commit

Permalink
change order of function calls when initializing a button
Browse files Browse the repository at this point in the history
  • Loading branch information
tasxatzial committed Apr 29, 2024
1 parent 9a4b734 commit afac82b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/js/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ import KeyboardUtils from './keyboardUtils.js';
*/
function ClickAndHold(btnEl, duration, Callbacks) {
const {onHoldStart, onHoldComplete, onHoldCancel} = Callbacks;
let state = initState();
const startEventsNames = ['mousedown', 'touchstart', 'keydown'];
const endEventsNames = ['keyup', 'blur', 'mouseup', 'mouseleave', 'touchend', 'touchcancel'];
addHoldStartListeners();
addHoldEndListeners();
let state = initState();
btnEl.style.setProperty('--hold-duration', duration + 'ms');
btnEl.setAttribute('data-click-and-hold', '');
addHoldEndListeners();
addHoldStartListeners();

function initState() {
return {
Expand Down
8 changes: 4 additions & 4 deletions src/js/animationFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ import KeyboardUtils from './keyboardUtils.js';
*/
function ClickAndHold(btnEl, duration, Callbacks) {
const {onHoldStart, onHoldComplete, onHoldCancel} = Callbacks;
let state = initState();
let animationState = initAnimationState();
const startEventsNames = ['mousedown', 'touchstart', 'keydown'];
const endEventsNames = ['keyup', 'blur', 'mouseup', 'mouseleave', 'touchend', 'touchcancel'];
addHoldStartListeners();
addHoldEndListeners();
let state = initState();
let animationState = initAnimationState();
btnEl.style.setProperty('--hold-duration', duration + 'ms');
btnEl.setAttribute('data-click-and-hold', '');
addHoldEndListeners();
addHoldStartListeners();

function initAnimationState() {
return {
Expand Down

0 comments on commit afac82b

Please sign in to comment.