Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
f2c5e49e
Commit
f2c5e49e
authored
Aug 28, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Sep 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Publish `sidebarLayoutChanged` event
parent
5ced2dce
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
sidebar.js
src/annotator/sidebar.js
+8
-7
sidebar-test.js
src/annotator/test/sidebar-test.js
+8
-0
No files found.
src/annotator/sidebar.js
View file @
f2c5e49e
...
...
@@ -166,10 +166,6 @@ export default class Sidebar extends Host {
* opposed to being resized via the sidebar's drag handles
*/
_notifyOfLayoutChange
(
expanded
)
{
if
(
!
this
.
onLayoutChange
)
{
return
;
}
// The sidebar structure is:
//
// [ Toolbar ][ ]
...
...
@@ -179,7 +175,7 @@ export default class Sidebar extends Host {
// The sidebar iframe is hidden or shown by adjusting the left margin of
// its container.
const
toolbarWidth
=
this
.
toolbarWidth
||
0
;
const
toolbarWidth
=
(
this
.
frame
&&
this
.
toolbar
.
getWidth
())
||
0
;
const
frame
=
this
.
frame
||
this
.
externalFrame
;
const
rect
=
frame
[
0
].
getBoundingClientRect
();
const
computedStyle
=
window
.
getComputedStyle
(
frame
[
0
]);
...
...
@@ -206,11 +202,16 @@ export default class Sidebar extends Host {
expanded
=
frameVisibleWidth
>
toolbarWidth
;
}
this
.
onLayoutChange
(
{
const
layoutState
=
{
expanded
,
width
:
expanded
?
frameVisibleWidth
:
toolbarWidth
,
height
:
rect
.
height
,
});
};
if
(
this
.
onLayoutChange
)
{
this
.
onLayoutChange
(
layoutState
);
}
this
.
publish
(
'sidebarLayoutChanged'
,
[
layoutState
]);
}
_onPan
(
event
)
{
...
...
src/annotator/test/sidebar-test.js
View file @
f2c5e49e
...
...
@@ -494,14 +494,22 @@ describe('Sidebar', () => {
});
it
(
'notifies when sidebar changes expanded state'
,
()
=>
{
sinon
.
stub
(
sidebar
,
'publish'
);
sidebar
.
show
();
assert
.
calledOnce
(
layoutChangeHandlerSpy
);
assert
.
calledOnce
(
sidebar
.
publish
);
assert
.
calledWith
(
sidebar
.
publish
,
'sidebarLayoutChanged'
,
sinon
.
match
.
any
);
assertLayoutValues
(
layoutChangeHandlerSpy
.
lastCall
.
args
[
0
],
{
expanded
:
true
,
});
sidebar
.
hide
();
assert
.
calledTwice
(
layoutChangeHandlerSpy
);
assert
.
calledTwice
(
sidebar
.
publish
);
assertLayoutValues
(
layoutChangeHandlerSpy
.
lastCall
.
args
[
0
],
{
expanded
:
false
,
width
:
fakeToolbar
.
getWidth
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment