In terms of efficiency, no it's not very efficient to run that code for every single pixel the mouse moves. What you could do is run that code after the mouse has stopped moving for x
miliseconds. Something like this:
var mouseTimer;
$(document).on('mousemove', function(e) {
clearTimeout(mouseTimer);
mouseTimer = setTimeout(function() {
var treshold = 50;
var action_dots = $('.branch[open][focus]').children('.branch-line').children('.action-dot');
var opacity = action_dots.css('opacity');
if (e.pageX >= ($(window).width() / 2 - treshold) && e.pageX <= ($(window).width() / 2 + treshold)) {
if (opacity == 0) {
action_dots.transition({ opacity: 1 }, 100);
}
}
else {
if (opacity == 1) {
action_dots.transition({ opacity: 0 }, 100);
}
}
}, 50); // runs 50ms after mouse movement stops.
});