Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
2a89c672
Commit
2a89c672
authored
5 years ago
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Support facing-pages and non-paged viewing hints
parent
9e576d47
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.eslintrc
+2
-1
2 additions, 1 deletion
.eslintrc
__tests__/src/lib/CanvasGroupings.test.js
+12
-1
12 additions, 1 deletion
__tests__/src/lib/CanvasGroupings.test.js
src/lib/CanvasGroupings.js
+43
-12
43 additions, 12 deletions
src/lib/CanvasGroupings.js
with
57 additions
and
14 deletions
.eslintrc
+
2
−
1
View file @
2a89c672
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
"sort-keys": ["error", "asc", {
"sort-keys": ["error", "asc", {
"caseSensitive": false,
"caseSensitive": false,
"natural": false
"natural": false
}]
}],
"no-underscore-dangle": "off",
}
}
}
}
This diff is collapsed.
Click to expand it.
__tests__/src/lib/CanvasGroupings.test.js
+
12
−
1
View file @
2a89c672
...
@@ -48,10 +48,21 @@ describe('CanvasGroupings', () => {
...
@@ -48,10 +48,21 @@ describe('CanvasGroupings', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
subject
=
new
CanvasGroupings
([
0
,
1
,
2
,
3
],
'
book
'
);
subject
=
new
CanvasGroupings
([
0
,
1
,
2
,
3
],
'
book
'
);
});
});
it
(
'
selects by index
/ 2
'
,
()
=>
{
it
(
'
selects by index
'
,
()
=>
{
expect
(
subject
.
getCanvases
(
2
)).
toEqual
([
1
,
2
]);
expect
(
subject
.
getCanvases
(
2
)).
toEqual
([
1
,
2
]);
});
});
});
});
describe
(
'
book with facing pages
'
,
()
=>
{
let
subject
;
beforeEach
(()
=>
{
subject
=
new
CanvasGroupings
([
0
,
1
,
{
getViewingHint
:
()
=>
'
facing-pages
'
,
id
:
2
},
3
],
'
book
'
);
});
it
(
'
selects by index
'
,
()
=>
{
expect
(
subject
.
getCanvases
(
1
)).
toEqual
([
1
]);
expect
(
subject
.
getCanvases
(
2
)[
0
].
id
).
toEqual
(
2
);
expect
(
subject
.
getCanvases
(
3
)).
toEqual
([
3
]);
});
});
describe
(
'
gallery
'
,
()
=>
{
describe
(
'
gallery
'
,
()
=>
{
it
(
'
selects by index
'
,
()
=>
{
it
(
'
selects by index
'
,
()
=>
{
const
subject
=
new
CanvasGroupings
([
0
,
1
,
2
,
3
]);
const
subject
=
new
CanvasGroupings
([
0
,
1
,
2
,
3
]);
...
...
This diff is collapsed.
Click to expand it.
src/lib/CanvasGroupings.js
+
43
−
12
View file @
2a89c672
...
@@ -7,15 +7,18 @@ export default class CanvasGroupings {
...
@@ -7,15 +7,18 @@ export default class CanvasGroupings {
constructor
(
canvases
,
viewType
=
'
single
'
)
{
constructor
(
canvases
,
viewType
=
'
single
'
)
{
this
.
canvases
=
canvases
;
this
.
canvases
=
canvases
;
this
.
viewType
=
viewType
;
this
.
viewType
=
viewType
;
this
.
_groupings
=
null
;
// eslint-disable-line no-underscore-dangle
this
.
_groupings
=
null
;
this
.
_canvasGroupingMap
=
null
;
}
}
/**
/**
*/
*/
getCanvases
(
index
)
{
getCanvases
(
index
)
{
switch
(
this
.
viewType
)
{
switch
(
this
.
viewType
)
{
case
'
scroll
'
:
return
this
.
groupings
()[
0
];
case
'
book
'
:
case
'
book
'
:
return
this
.
groupings
()[
Math
.
ceil
(
index
/
2
)
];
return
this
.
groupings
()[
this
.
_canvasGroupingMap
[
index
]
];
default
:
default
:
return
this
.
groupings
()[
index
];
return
this
.
groupings
()[
index
];
}
}
...
@@ -26,27 +29,55 @@ export default class CanvasGroupings {
...
@@ -26,27 +29,55 @@ export default class CanvasGroupings {
* of canvases, while book view creates pairs.
* of canvases, while book view creates pairs.
*/
*/
groupings
()
{
groupings
()
{
if
(
this
.
_groupings
)
{
// eslint-disable-line no-underscore-dangle
if
(
this
.
_groupings
)
{
return
this
.
_groupings
;
// eslint-disable-line no-underscore-dangle
return
this
.
_groupings
;
}
}
if
(
this
.
viewType
!==
'
book
'
)
{
if
(
this
.
viewType
!==
'
book
'
)
{
return
this
.
canvases
.
map
(
canvas
=>
[
canvas
]);
return
this
.
canvases
.
map
(
canvas
=>
[
canvas
]);
}
}
const
groupings
=
[];
const
groupings
=
[];
const
canvasGroupingMap
=
[];
let
groupIndex
=
0
;
this
.
canvases
.
forEach
((
canvas
,
i
)
=>
{
this
.
canvases
.
forEach
((
canvas
,
i
)
=>
{
if
(
!
groupings
[
groupIndex
])
{
groupings
[
groupIndex
]
=
[];
}
canvasGroupingMap
[
i
]
=
groupIndex
;
if
(
i
===
0
)
{
if
(
i
===
0
)
{
groupings
.
push
([
canvas
]);
canvasGroupingMap
[
i
]
=
groupIndex
;
groupings
[
groupIndex
].
push
(
canvas
);
groupIndex
+=
1
;
return
;
}
const
hint
=
canvas
&&
(
(
canvas
.
getBehavior
&&
canvas
.
getBehavior
())
||
(
canvas
.
getViewingHint
&&
canvas
.
getViewingHint
())
);
if
(
hint
===
'
facing-pages
'
||
hint
===
'
non-paged
'
)
{
if
(
groupings
[
groupIndex
].
length
>
0
)
{
groupIndex
+=
1
;
canvasGroupingMap
[
i
]
=
groupIndex
;
}
groupings
[
groupIndex
]
=
[
canvas
];
groupIndex
+=
1
;
return
;
return
;
}
}
// Odd page
if
(
i
%
2
!==
0
)
{
if
(
groupings
[
groupIndex
].
length
<
2
)
{
groupings
.
push
([
canvas
]);
groupings
[
groupIndex
].
push
(
canvas
);
}
else
{
}
// Even page
groupings
[
Math
.
ceil
(
i
/
2
)].
push
(
canvas
);
if
(
groupings
[
groupIndex
].
length
===
2
)
{
groupIndex
+=
1
;
}
}
});
});
this
.
_groupings
=
groupings
;
// eslint-disable-line no-underscore-dangle
this
.
_groupings
=
groupings
;
this
.
_canvasGroupingMap
=
canvasGroupingMap
;
return
groupings
;
return
groupings
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment