1. function onMouseMove(event) {
    2. moveAt(event.pageX, event.pageY);
    3. ball.hidden = true;
    4. let elemBelow = document.elementFromPoint(event.clientX, event.clientY);
    5. ball.hidden = false;
    6. if (!elemBelow) return;
    7. let droppableBelow = elemBelow.closest('.droppable');
    8. if (currentDroppable != droppableBelow) {
    9. if (currentDroppable) { // null when we were not over a droppable before this event
    10. leaveDroppable(currentDroppable);
    11. }
    12. currentDroppable = droppableBelow;
    13. if (currentDroppable) { // null if we're not coming over a droppable now
    14. // (maybe just left the droppable)
    15. enterDroppable(currentDroppable);
    16. }
    17. }
    18. }

    一开始,currentDroppable是null,判断不相等,然后:
    如果此时球在球门上,则droppableBelow是真,currentDroppable也是真,进入球门
    如果球不在球门上,则没有任何操作,保持原样;

    假设上次进入球门了,currentDroppable是真
    如果此时球在球门上,两者相同,没有变化;
    如果不在了,则离开球门,current变为null,droppableBelow也是null,回到初始状态。