Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
pagedjs
pagedjs
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 161
    • Issues 161
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 12
    • Merge Requests 12
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Tools
  • pagedjspagedjs
  • Merge Requests
  • !124

Merged
Opened Jun 12, 2020 by Guillaume@mogztter
  • Report abuse
Report abuse

resolves #214 fix page counter

According to the specification the counter named page can be explicitly defined in the page context:

A counter named page is automatically created and incremented by 1 on every page of the document, unless the counter-increment property in the page context explicitly specifies a different increment for the page counter.

This merge request makes the page counter increment configurable by using a variable in the CSS counter-increment: page var(--pagedjs-page-counter-increment);. The default value is 1.

I've created a PageCounterIncrement to set the variable --pagedjs-page-counter-increment when the property counter-increment is defined in a page context for the counter named "page".

I've updated TargetCounters to increment the value accordingly. Please note that the value can be negative (i.e. counter-increment: page -1).

I've also fixed a potential bug (still need to create a test case) in counters.js where number was defined as:

counter.increments[selector] = {
  selector: selector,
  number: number || 1
};

The issue here is that number can be 0 and 0 is falsy... so if you declare counter-increment: foo 0 it will actually increment foo by 1 😬 Instead I'm using the following code:

const number = declaration.value.children.getSize() > 1 ? declaration.value.children.last().value : 1;

If the value is defined (i.e. declaration.value.children.getSize() > 1 is true) then use whatever the value is, otherwise, if the value is missing, use a default value of 1.

resolves #214 (closed)

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch https://gitlab.pagedmedia.org/mogztter/pagedjs.git issue-214-page-target-counter
git checkout -b mogztter/pagedjs-issue-214-page-target-counter FETCH_HEAD

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/master
git merge --no-ff mogztter/pagedjs-issue-214-page-target-counter

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 0
  • Commits 2
  • Pipelines 2
  • Changes 23
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: tools/pagedjs!124

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.