collectActivations()

in projects/libs/flex-layout/core/media-marshaller/print-hook.ts [213:238]


  collectActivations(target: HookTarget, event: MediaChange) {
    if (!this.isPrinting || this.isPrintingBeforeAfterEvent) {
      if (!this.isPrintingBeforeAfterEvent) {
        // Only clear deactivations if we aren't printing from a `beforeprint` event.
        // Otherwise, this will clear before `stopPrinting()` is called to restore
        // the pre-Print Activations.
        this.deactivations = [];

        return;
      }

      if (!event.matches) {
        const bp = this.breakpoints.findByQuery(event.mediaQuery);
        // Deactivating a breakpoint
        if (bp) {
          const hasFormerBp = this.formerActivations && this.formerActivations.includes(bp);
          const wasActivated = !this.formerActivations && target.activatedBreakpoints.includes(bp);
          const shouldDeactivate = hasFormerBp || wasActivated;
          if (shouldDeactivate) {
            this.deactivations.push(bp);
            this.deactivations.sort(sortDescendingPriority);
          }
        }
      }
    }
  }