Navigation Logic Test

Testing the stepVisualLeft/Right logic for RTL (Urdu) and LTR books.

One-Page Mode

LTR Book (English/Hindi):
- Click Left Arrow: should go to previous page (backward, -1)
- Click Right Arrow: should go to next page (forward, +1)
- Press ArrowLeft: same as Left Arrow button
- Press ArrowRight: same as Right Arrow button
RTL Book (Urdu):
- Click Left Arrow: should go to next page visually (forward, +1)
- Click Right Arrow: should go to previous page visually (backward, -1)
- Press ArrowLeft: same as Left Arrow button
- Press ArrowRight: same as Right Arrow button

Two-Page Mode

LTR Book (English/Hindi):
- Click Left Arrow: should go back 2 pages (backward, -2)
- Click Right Arrow: should go forward 2 pages (forward, +2)
Layout: left page on left, right page on right
RTL Book (Urdu):
- Click Left Arrow: should go forward 2 pages (forward, +2)
- Click Right Arrow: should go back 2 pages (backward, -2)
Layout: right page on right, left page on left

Current Implementation Logic


stepVisualLeft():
  delta = (isTwoPageMode ? 2 : 1)
  if (isUrduBook) {
    delta = delta         // +1 or +2
  } else {
    delta = -delta        // -1 or -2
  }
  nextIndex = currentIndex + delta

stepVisualRight():
  delta = (isTwoPageMode ? 2 : 1)
  if (isUrduBook) {
    delta = -delta        // -1 or -2
  } else {
    delta = delta         // +1 or +2
  }
  nextIndex = currentIndex + delta
    

Test Cases:

Case 1: LTR One-Page (English)
isUrduBook=false, isTwoPageMode=false
stepVisualLeft: delta = 1 → -1 = -1 (go back)
stepVisualRight: delta = 1 → 1 = 1 (go forward)
Case 2: RTL One-Page (Urdu)
isUrduBook=true, isTwoPageMode=false
stepVisualLeft: delta = 1 → 1 = 1 (go forward)
stepVisualRight: delta = 1 → -1 = -1 (go back)
Case 3: LTR Two-Page (English)
isUrduBook=false, isTwoPageMode=true
stepVisualLeft: delta = 2 → -2 = -2 (go back 2)
stepVisualRight: delta = 2 → 2 = 2 (go forward 2)
Case 4: RTL Two-Page (Urdu)
isUrduBook=true, isTwoPageMode=true
stepVisualLeft: delta = 2 → 2 = 2 (go forward 2)
stepVisualRight: delta = 2 → -2 = -2 (go back 2)

Debugging Steps:

  1. Open the browser's Developer Console (F12)
  2. Load a Urdu book URL (one with ?lang=ur)
  3. Check that the console logs: "isUrduBook: true"
  4. Check that the cache badge shows "Manifest cached - Urdu navigation enabled"
  5. Open the reader and switch to two-page view
  6. Click left/right arrows and watch the console logs
  7. Verify that visual positions match expected navigation