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
d00ff041
Commit
d00ff041
authored
Apr 25, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `scrollToAnnotation` handler to reduce nesting
parent
a0367a19
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
guest.js
src/annotator/guest.js
+18
-19
No files found.
src/annotator/guest.js
View file @
d00ff041
...
@@ -293,12 +293,13 @@ export default class Guest {
...
@@ -293,12 +293,13 @@ export default class Guest {
});
});
this
.
crossframe
.
on
(
'scrollToAnnotation'
,
tag
=>
{
this
.
crossframe
.
on
(
'scrollToAnnotation'
,
tag
=>
{
for
(
let
anchor
of
this
.
anchors
)
{
const
anchor
=
this
.
anchors
.
find
(
a
=>
a
.
annotation
.
$tag
===
tag
);
if
(
anchor
.
highlights
)
{
if
(
!
anchor
?.
highlights
)
{
if
(
anchor
.
annotation
.
$tag
===
tag
)
{
return
;
}
const
range
=
resolveAnchor
(
anchor
);
const
range
=
resolveAnchor
(
anchor
);
if
(
!
range
)
{
if
(
!
range
)
{
continue
;
return
;
}
}
const
event
=
new
CustomEvent
(
'scrolltorange'
,
{
const
event
=
new
CustomEvent
(
'scrolltorange'
,
{
...
@@ -307,12 +308,10 @@ export default class Guest {
...
@@ -307,12 +308,10 @@ export default class Guest {
detail
:
range
,
detail
:
range
,
});
});
const
defaultNotPrevented
=
this
.
element
.
dispatchEvent
(
event
);
const
defaultNotPrevented
=
this
.
element
.
dispatchEvent
(
event
);
if
(
defaultNotPrevented
)
{
if
(
defaultNotPrevented
)
{
scrollIntoView
(
anchor
.
highlights
[
0
]);
scrollIntoView
(
anchor
.
highlights
[
0
]);
}
}
}
}
}
});
});
// Handler for when sidebar requests metadata for the current document
// Handler for when sidebar requests metadata for the current document
...
...
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