Seeking assistance with a swinging motion using two simple functions in Javascript. As a newcomer to the language, I am looking for guidance to achieve my goal.
First function:
function up() {
imgObj.style.left = parseInt(imgObj.style.transform = 'rotate(45deg)');
// This function creates the upward swinging motion.
function down() {
`imgObj.style.left = parseInt(imgObj.style.transform = 'rotate(27deg)'); // This function returns back to the original state.
While I can make both functions work separately, I need to call them in the following order:
up();
down() // After 0.5 seconds
up() // Another 0.5 seconds after calling down()
and down() // 0.5 seconds after the previous up() call
.
I have tried using setTimeout(function, timedelay) without success. Any help would be appreciated greatly.