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
f333e64f
Commit
f333e64f
authored
Apr 06, 2018
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `Adder#showAt` a method
parent
495e4e2e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
41 deletions
+41
-41
adder.js
src/annotator/adder.js
+41
-41
No files found.
src/annotator/adder.js
View file @
f333e64f
...
...
@@ -240,49 +240,49 @@ class Adder {
return
{
top
,
left
,
arrowDirection
};
};
}
/**
* Show the adder at the given position and with the arrow pointing in
* `arrowDirection`.
*
* @param {number} left - Horizontal offset from left edge of viewport.
* @param {number} top - Vertical offset from top edge of viewport.
*/
this
.
showAt
=
(
left
,
top
,
arrowDirection
)
=>
{
this
.
element
.
className
=
classnames
({
'annotator-adder'
:
true
,
'annotator-adder--arrow-down'
:
arrowDirection
===
ARROW_POINTING_DOWN
,
'annotator-adder--arrow-up'
:
arrowDirection
===
ARROW_POINTING_UP
,
});
// Some sites make big assumptions about interactive
// elements on the page. Some want to hide interactive elements
// after use. So we need to make sure the button stays displayed
// the way it was originally displayed - without the inline styles
// See: https://github.com/hypothesis/client/issues/137
this
.
element
.
querySelector
(
ANNOTATE_BTN_SELECTOR
).
style
.
display
=
''
;
this
.
element
.
querySelector
(
HIGHLIGHT_BTN_SELECTOR
).
style
.
display
=
''
;
// Translate the (left, top) viewport coordinates into positions relative to
// the adder's nearest positioned ancestor (NPA).
//
// Typically the adder is a child of the `<body>` and the NPA is the root
// `<html>` element. However page styling may make the `<body>` positioned.
// See https://github.com/hypothesis/client/issues/487.
var
positionedAncestor
=
nearestPositionedAncestor
(
this
.
_container
);
var
parentRect
=
positionedAncestor
.
getBoundingClientRect
();
Object
.
assign
(
this
.
_container
.
style
,
{
top
:
toPx
(
top
-
parentRect
.
top
),
left
:
toPx
(
left
-
parentRect
.
left
),
});
this
.
element
.
style
.
visibility
=
'visible'
;
/**
* Show the adder at the given position and with the arrow pointing in
* `arrowDirection`.
*
* @param {number} left - Horizontal offset from left edge of viewport.
* @param {number} top - Vertical offset from top edge of viewport.
*/
showAt
(
left
,
top
,
arrowDirection
)
{
this
.
element
.
className
=
classnames
({
'annotator-adder'
:
true
,
'annotator-adder--arrow-down'
:
arrowDirection
===
ARROW_POINTING_DOWN
,
'annotator-adder--arrow-up'
:
arrowDirection
===
ARROW_POINTING_UP
,
});
clearTimeout
(
this
.
_enterTimeout
);
this
.
_enterTimeout
=
setTimeout
(()
=>
{
this
.
element
.
className
+=
' is-active'
;
},
1
);
};
// Some sites make big assumptions about interactive
// elements on the page. Some want to hide interactive elements
// after use. So we need to make sure the button stays displayed
// the way it was originally displayed - without the inline styles
// See: https://github.com/hypothesis/client/issues/137
this
.
element
.
querySelector
(
ANNOTATE_BTN_SELECTOR
).
style
.
display
=
''
;
this
.
element
.
querySelector
(
HIGHLIGHT_BTN_SELECTOR
).
style
.
display
=
''
;
// Translate the (left, top) viewport coordinates into positions relative to
// the adder's nearest positioned ancestor (NPA).
//
// Typically the adder is a child of the `<body>` and the NPA is the root
// `<html>` element. However page styling may make the `<body>` positioned.
// See https://github.com/hypothesis/client/issues/487.
var
positionedAncestor
=
nearestPositionedAncestor
(
this
.
_container
);
var
parentRect
=
positionedAncestor
.
getBoundingClientRect
();
Object
.
assign
(
this
.
_container
.
style
,
{
top
:
toPx
(
top
-
parentRect
.
top
),
left
:
toPx
(
left
-
parentRect
.
left
),
});
this
.
element
.
style
.
visibility
=
'visible'
;
clearTimeout
(
this
.
_enterTimeout
);
this
.
_enterTimeout
=
setTimeout
(()
=>
{
this
.
element
.
className
+=
' is-active'
;
},
1
);
}
}
...
...
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