feat: tablerowloop object

See: https://www.rubydoc.info/gems/liquid/Liquid/TablerowloopDrop
This commit is contained in:
Jun Yang
2019-03-02 06:00:30 +08:00
parent cca0306f5b
commit 3647305dcf
8 changed files with 121 additions and 129 deletions
+25
View File
@@ -0,0 +1,25 @@
import { ForloopDrop } from './forloop-drop'
export class TablerowloopDrop extends ForloopDrop {
private cols: number
constructor (length: number, cols: number) {
super(length)
this.length = length
this.cols = cols
}
row () {
return Math.floor(this.i / this.cols) + 1
}
col0 () {
return (this.i % this.cols)
}
col () {
return this.col0() + 1
}
col_first () { // eslint-disable-line
return this.col0() === 0
}
col_last () { // eslint-disable-line
return this.col() === this.cols
}
}