Save values in Javascript elements - Good practices

1

I wonder if it's a good practice to store values directly in the elements so you do not have to recalculate. For example:

function scrollfunc(e){
    var el = e.currentTarget;
    var deltaY = (el.deltaY !== undefined)? (el.deltaY + e.y) : e.y;

    el.style.transform = 'translateY(' + deltaY + 'px)';
    el.deltaY = deltaY;
}

document.getElementById('#scrollElement').addEventListener(scrollfunc);
    
asked by anonymous 25.07.2018 / 16:52

0 answers