# ChangeLog

## pdf.js
### Line 1
```js
const pdfjsPath = path => { // TODO: EBOOK
  const url = `/vendor/pdfjs/${path}`;
  // const url = new URL(`./vendor/pdfjs/${path}`, import.meta.url).toString();
  console.log('pdfjsPath', url);
  return url;
}
```

## view.js
### Line 328, in #onRelocate
```js
if (reason === 'page' || reason === 'snap') { // TODO: EBOOK (Reset scroll)
  if (this.renderer) {
    this.renderer.scrollTop = 0;
    this.renderer.scrollLeft = 0;
  }
}
```

```js
const chapterLocation = { // TODO: EBOOK
  current: this.renderer.page,
  total: this.renderer.pages - 2
}
```

### Line 336, lastLocation
```js
this.lastLocation = { ...progress, tocItem, pageItem, cfi, range, chapterLocation } // TODO: EBOOK
```

### Line 348, after `#handleLinks`
```js
    // TODO: EBOOK
    #handleImage(doc) {
      for (const img of doc.querySelectorAll('img')) {
        img.addEventListener('click', e => {
          e.preventDefault()
          e.stopPropagation()
          this.#emit('click-image', { img })
        })
      }
    }
    // TODO: EBOOK
    #handleClick(doc) {
      doc.addEventListener('click', e => {
        if (doc.getSelection().type === "Range")
          return

        let { clientX, clientY } = e
        // add top margin to y, y is relative to the iframe
        const topMargin = this.renderer.getAttribute('top-margin').match(/\d+/)[0]
        clientY += parseInt(topMargin)

        this.renderer.scrollProp == 'scrollLeft'
          ? clientX -= (this.renderer.start - this.renderer.size)
          : clientY -= (this.renderer.start)

        this.#emit('click-view', { x: clientX, y: clientY })
      })
      this.renderer.addEventListener('click', e => {
        let { clientX, clientY } = e
        while (clientX > window.innerWidth) {
          clientX -= window.innerWidth
        }
        this.#emit('click-view', { x: clientX, y: clientY })
      })
    }
```

## tts.js
### Line 172, move
```js
// TODO: EBOOK(optional move)
next(move = true) {
  const newIndex = this.#index + 1
  if (this.#arr[newIndex]) {
    if (move) this.#index = newIndex
    return this.#f(this.#arr[newIndex])
  }
  while (true) {
    const { done, value } = this.#iter.next()
    if (done) break
    this.#arr.push(value)
    if (this.#arr[newIndex]) {
      if (move) this.#index = newIndex
      return this.#f(this.#arr[newIndex])
    }
  }
}
```

### Line 255
```js
// TODO: EBOOK(optional move)
next(paused, move = true) {
  this.#lastMark = null
  const [doc, range] = this.#list.next(move) ?? []
  if (paused && range && move) this.highlight(range.cloneRange())
  return this.#speak(doc)
}
```

### Line 260, from(range)

```js
    // TODO: EBOOK (highlight speak range)
    from(range) {
        this.#lastMark = null
        const [doc, r] = this.#list.find(range_ =>
            range.compareBoundaryPoints(Range.END_TO_START, range_) <= 0)
        const speakRange = doc.createRange()
        speakRange.setEnd(r.endContainer, r.endOffset)

        let mark
        for (const [name, range_] of this.#ranges.entries())
            if (range.compareBoundaryPoints(Range.START_TO_START, range_) <= 0) {
                mark = name
                speakRange.setStart(range_.startContainer, range_.startOffset)
                break
            }

        this.highlight(speakRange.cloneRange())
        return this.#speak(doc, ssml => this.#getMarkElement(ssml, mark))
    }
```

## fixed-layout.js
### Line 112
```js
const portrait = this.spread !== 'both' && this.spread !== 'portrait'
            && (height > width || width < 2 * 1000) // TODO: EBOOK (col width: 1000px)
```

### Line 118
```js
// TODO: EBOOK
// In Fit Width mode, avoid introducing a horizontal scrollbar caused by the vertical scrollbar squeezing the content width.
const scrollbarWidth = 16
const pageRatio = (target.height / target.width)
const willScrollY = (width * pageRatio) > height
const adjustedWidth = willScrollY ? (width - scrollbarWidth) : width
```
