WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f96508c

Browse files
KasoKaso
authored andcommitted
Fixing spinny button to be closer to desktop animation
1 parent 7e79a02 commit f96508c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/js/main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ spinner.addEventListener('click', () => {
3333
spin(firstNameBox, lastNameBox);
3434
});
3535

36+
spinner.addEventListener('touchstart', () => {
37+
spinUp();
38+
});
39+
40+
spinner.addEventListener('touchcancel', () => {
41+
spinOut();
42+
});
43+
3644
/**
3745
* spin: executes logic to populate the input fields on click of the spinner button
3846
* @param {HTMLInputElement} firstBox - firstNameBox text input from document
@@ -45,6 +53,16 @@ function spin(firstBox, lastBox) {
4553
// Shove names in boxes
4654
firstBox.value = firstName;
4755
lastBox.value = lastName;
56+
spinOut();
57+
}
58+
59+
function spinUp() {
60+
spinner.style.transform = 'rotate(180deg)';
61+
}
62+
63+
function spinOut() {
64+
spinner.style.transform = 'rotate(0)';
65+
spinner.style.transition = 'transform 0.3s';
4866
}
4967

5068
/**

0 commit comments

Comments
 (0)