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
4a09c7c9
Commit
4a09c7c9
authored
Nov 27, 2012
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework dragging to use rAF
parent
7c8acc6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
26 deletions
+43
-26
annotator.host.coffee
h/js/src/annotator.host.coffee
+33
-14
controllers.coffee
h/js/src/controllers.coffee
+6
-11
inject.scss
h/sass/inject.scss
+4
-1
No files found.
h/js/src/annotator.host.coffee
View file @
4a09c7c9
...
...
@@ -22,6 +22,11 @@ class Annotator.Host extends Annotator
# timer used to throttle event frequency
updateTimer
:
null
# Drag state variables
drag
:
delta
:
0
tick
:
false
constructor
:
(
element
,
options
)
->
super
...
...
@@ -63,20 +68,19 @@ class Annotator.Host extends Annotator
setupAnnotation
:
=>
this
.
setupAnnotation
arguments
...
onEditorHide
:
this
.
onEditorHide
onEditorSubmit
:
this
.
onEditorSubmit
showFrame
:
=>
@
frame
.
removeClass
(
'annotator-collapsed'
)
hideFrame
:
=>
@
frame
.
addClass
(
'annotator-collapsed'
)
resetFrameWidth
:
=>
@
frame
.
css
({
"width"
:
""
,
"margin-left"
:
""
})
setFrameWidth
:
(
width
)
=>
@
frame
.
css
({
"width"
:
width
,
"margin-left"
:
(
-
1
)
*
width
})
addToFrameWidth
:
(
width
,
innerWidth
)
=>
if
isNaN
(
parseInt
(
@
frame
[
0
].
style
.
width
))
old
=
innerWidth
else
old
=
parseInt
(
@
frame
[
0
].
style
.
width
)
@
frame
.
css
width
:
old
+
width
'margin-left'
:
-
(
old
+
width
)
showFrame
:
=>
@
frame
.
css
'margin-left'
:
"
#{
-
1
*
@
frame
.
width
()
}
px"
@
frame
.
removeClass
'annotator-no-transition'
@
frame
.
removeClass
'annotator-collapsed'
hideFrame
:
=>
@
frame
.
css
'margin-left'
:
''
@
frame
.
removeClass
'annotator-no-transition'
@
frame
.
addClass
'annotator-collapsed'
dragFrame
:
(
d
)
=>
@
drag
.
delta
+=
d
unless
@
drag
.
tick
@
drag
.
tick
=
true
requestAnimationFrame
@
dragRefresh
getHighlights
:
=>
highlights
:
$
(
@
wrapper
).
find
(
'.annotator-hl'
).
map
->
offset
:
$
(
this
).
offset
()
...
...
@@ -173,6 +177,21 @@ class Annotator.Host extends Annotator
_setupEditor
:
->
true
dragRefresh
:
=>
d
=
@
drag
.
delta
@
drag
.
delta
=
0
@
drag
.
tick
=
false
m
=
parseInt
(
getComputedStyle
@
frame
[
0
]).
marginLeft
w
=
-
1
*
m
m
+=
d
w
-=
d
@
frame
.
addClass
'annotator-no-transition'
@
frame
.
css
'margin-left'
:
"
#{
m
}
px"
width
:
"
#{
w
}
px"
showEditor
:
(
annotation
)
=>
stub
=
ranges
:
annotation
.
ranges
...
...
h/js/src/controllers.coffee
View file @
4a09c7c9
...
...
@@ -5,7 +5,6 @@ class Hypothesis extends Annotator
this
::
hash
=
-
1
# * cheap UUID :cake:
this
::
cache
=
{}
# * object cache
this
::
visible
=
false
# * Whether the sidebar is visible
this
::
lastWidth
=
0
# * Frame's width before close
# Plugin configuration
options
:
...
...
@@ -75,9 +74,7 @@ class Hypothesis extends Annotator
onEditorSubmit
:
{}
showFrame
:
{}
hideFrame
:
{}
resetFrameWidth
:
{}
setFrameWidth
:
{}
addToFrameWidth
:
{}
dragFrame
:
{}
getHighlights
:
{}
setActiveHighlights
:
{}
getMaxBottom
:
{}
...
...
@@ -169,7 +166,6 @@ class Hypothesis extends Annotator
this
_setupDocumentEvents
:
->
dragStart
=
0
@
element
.
find
(
'#toolbar .tri'
).
click
=>
if
@
visible
this
.
hide
()
...
...
@@ -178,15 +174,16 @@ class Hypothesis extends Annotator
this
.
_fillDynamicBucket
()
this
.
show
()
dragLast
=
0
handle
=
@
element
.
find
(
'#toolbar .tri'
)[
0
]
handle
.
addEventListener
'dragstart'
,
(
event
)
=>
drag
Star
t
=
event
.
screenX
drag
Las
t
=
event
.
screenX
handle
.
addEventListener
'dragend'
,
(
event
)
=>
@
provider
.
addToFrameWidth
(
dragStart
-
event
.
screenX
),
window
.
innerWidth
@
provider
.
dragFrame
(
event
.
screenX
-
dragLast
)
handle
.
addEventListener
'drag'
,
(
event
)
=>
if
event
.
screenX
>
0
@
provider
.
addToFrameWidth
(
dragStart
-
event
.
screenX
),
window
.
innerWidth
drag
Star
t
=
event
.
screenX
@
provider
.
dragFrame
(
event
.
screenX
-
dragLast
)
drag
Las
t
=
event
.
screenX
this
_setupDynamicStyle
:
->
...
...
@@ -609,7 +606,6 @@ class Hypothesis extends Annotator
annotations
=
@
heatmap
.
buckets
[
@
bucket
]
?
.
map
(
a
)
=>
a
.
hash
.
valueOf
()
@
visible
=
true
if
@
lastWidth
>
0
then
@
provider
.
setFrameWidth
(
@
lastWidth
)
@
provider
.
setActiveHighlights
annotations
@
provider
.
showFrame
()
@
element
.
find
(
"#toolbar"
).
addClass
"shown"
...
...
@@ -619,7 +615,6 @@ class Hypothesis extends Annotator
@
lastWidth
=
window
.
innerWidth
@
visible
=
false
@
provider
.
setActiveHighlights
[]
@
provider
.
resetFrameWidth
()
@
provider
.
hideFrame
()
@
element
.
find
(
"#toolbar"
).
removeClass
"shown"
document
.
getElementsByClassName
(
'tri'
)[
0
].
draggable
=
false
...
...
h/sass/inject.scss
View file @
4a09c7c9
...
...
@@ -108,10 +108,13 @@
&
.annotator-collapsed
{
margin-left
:
-
$heatmap-width
-
17px
;
}
}
.annotator-no-transition
{
@include
transition
(
none
!
important
);
}
/*
Mobile layout
...
...
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