earthquake

earthquake!

< Feedback on earthquake

Review: OK - script works, but has bugs

NotYouMod
§
Posted: 2023-04-14
Edited: 2023-04-14

Hi fellow developer! You forgot to call a function on line 15!

There is fixed code:

(function() {
    'use strict';

    const elements = document.querySelectorAll('body *')

    elements.forEach(elem => {
        elem.addEventListener('mouseenter', () => {
            elem.style.position = 'relative';
            elem.style.top = Math.random() * 100 + 'px';
        })
    })
})();

I also modified it a bit to make it work only with <body>'s children, and changed positioning from absolute to relative, so elements won't stack.

Post reply

Sign in to post a reply.