All files / core/scrollers side-scroller.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26          3x   5229x         2688x 2688x 176568x       2688x 2688x 176568x     2688x    
import { bit } from "../../utils/bit-array";
import { PanelFrame } from "../../types";
import { Panel } from "../panel";
import { Scroller } from "./scroller";
 
export default class SideScroller implements Scroller {
  public loopEndIndex(params: Panel): number {
    return params.board.width - 1;
  }
 
  public generatePanelFrameAtIndex(currentIndex: number, panel: Panel): PanelFrame {
    // Get all the columns involved in the next PanelFrame
    let columns: bit[][] = [];
    for(let i = 0; i < panel.width; i++) {
      columns.push(panel.board.getColumnAtIndex(currentIndex + i));
    }
 
    // Build the panel frame from the columns
    let panelFrame: PanelFrame = [];
    for(let i = 0; i < columns[0].length; i++) {
      panelFrame.push(columns.map(x => x[i]));
    }
 
    return panelFrame;
  }
}