Calculating direction based on index of array
"none" can be treated as a default returned value, thus eliminating multiple occurrences of direction = "none" assignment. In that way it'd be enough to just consider non-none cases:

function getDirection(component) {
    let oldIndex, newIndex,
        lastComp = this.lastComponentInViewport;

    if (lastComp) {
        oldIndex = this.components.indexOf(lastComp);
        newIndex = this.components.indexOf(component);
        if (newIndex &gt; oldIndex) return "next";
        if (newIndex &lt; oldIndex) return "previous";
    }
    return "none";
}