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