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
e1d17fe9
Unverified
Commit
e1d17fe9
authored
Feb 27, 2020
by
Robert Knight
Committed by
GitHub
Feb 27, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1851 from hypothesis/remove-window-scroll-directive
Remove non-functional `window-scroll` Angular directive
parents
eb8d8687
015016c0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
154 deletions
+5
-154
stream-content.js
src/sidebar/components/stream-content.js
+0
-2
window-scroll-test.js
src/sidebar/directive/test/window-scroll-test.js
+0
-112
window-scroll.js
src/sidebar/directive/window-scroll.js
+0
-28
index.js
src/sidebar/index.js
+0
-5
stream-content.html
src/sidebar/templates/stream-content.html
+5
-7
No files found.
src/sidebar/components/stream-content.js
View file @
e1d17fe9
...
@@ -62,8 +62,6 @@ function StreamContentController(
...
@@ -62,8 +62,6 @@ function StreamContentController(
// Sort the stream so that the newest annotations are at the top
// Sort the stream so that the newest annotations are at the top
store
.
setSortKey
(
'Newest'
);
store
.
setSortKey
(
'Newest'
);
this
.
loadMore
=
fetch
;
}
}
export
default
{
export
default
{
...
...
src/sidebar/directive/test/window-scroll-test.js
deleted
100644 → 0
View file @
eb8d8687
import
angular
from
'angular'
;
const
inject
=
angular
.
mock
.
inject
;
import
windowScroll
from
'../window-scroll'
;
describe
(
'windowScroll'
,
function
()
{
let
directive
=
null
;
let
doc
=
null
;
let
html
=
null
;
let
view
=
null
;
let
scope
=
null
;
let
elem
=
null
;
let
attr
=
null
;
beforeEach
(
inject
(
function
(
$injector
)
{
directive
=
$injector
.
invoke
(
windowScroll
);
html
=
{};
view
=
{
addEventListener
:
sinon
.
spy
(),
removeEventListener
:
sinon
.
spy
(),
};
doc
=
{
documentElement
:
html
,
defaultView
:
view
};
scope
=
{
$apply
:
sinon
.
stub
().
yields
(),
$on
:
sinon
.
stub
()
};
elem
=
{
prop
:
sinon
.
stub
()
.
withArgs
(
'ownerDocument'
)
.
returns
(
doc
),
};
attr
=
{
windowScroll
:
sinon
.
stub
()
};
directive
.
link
(
scope
,
elem
,
attr
);
}));
it
(
'installs a scroll handler on the window'
,
function
()
{
assert
.
calledOnce
(
view
.
addEventListener
);
assert
.
calledWith
(
view
.
addEventListener
,
'scroll'
,
sinon
.
match
.
func
);
assert
.
calledOnce
(
scope
.
$on
);
assert
.
calledWith
(
scope
.
$on
,
'$destroy'
,
sinon
.
match
.
func
);
scope
.
$on
.
firstCall
.
args
[
1
]();
const
handler
=
view
.
addEventListener
.
firstCall
.
args
[
1
];
assert
.
calledOnce
(
view
.
removeEventListener
);
assert
.
calledWith
(
view
.
removeEventListener
,
'scroll'
,
handler
);
});
describe
(
'attribute argument'
,
function
()
{
let
callback
=
null
;
let
handler
=
null
;
beforeEach
(
function
()
{
callback
=
attr
.
windowScroll
;
handler
=
view
.
addEventListener
.
firstCall
.
args
[
1
];
html
.
clientHeight
=
100
;
html
.
scrollHeight
=
1000
;
view
.
scrollY
=
0
;
});
it
(
'is not called when scrolling near the top of the view'
,
function
()
{
handler
();
assert
.
notCalled
(
callback
);
});
it
(
'is not called when scrolling near the middle of the view'
,
function
()
{
handler
();
view
.
scrollY
=
500
;
handler
();
assert
.
notCalled
(
callback
);
});
it
(
'is called when one screen remains'
,
function
()
{
handler
();
view
.
scrollY
=
800
;
handler
();
assert
.
calledOnce
(
callback
);
});
describe
(
'throttle'
,
function
()
{
it
(
'prevents extraneous calls'
,
function
()
{
view
.
scrollY
=
800
;
handler
();
handler
();
assert
.
calledOnce
(
callback
);
});
it
(
'allows calls after the view grows'
,
function
()
{
view
.
scrollY
=
800
;
handler
();
assert
.
calledOnce
(
callback
);
html
.
scrollHeight
=
2000
;
handler
();
assert
.
calledOnce
(
callback
);
view
.
scrollY
=
1800
;
handler
();
assert
.
calledTwice
(
callback
);
});
});
});
});
src/sidebar/directive/window-scroll.js
deleted
100644 → 0
View file @
eb8d8687
export
default
function
windowScrollDirective
()
{
return
{
link
:
function
(
scope
,
elem
,
attr
)
{
let
active
=
true
;
const
html
=
elem
.
prop
(
'ownerDocument'
).
documentElement
;
const
view
=
elem
.
prop
(
'ownerDocument'
).
defaultView
;
function
onScroll
()
{
const
clientHeight
=
html
.
clientHeight
;
const
scrollHeight
=
html
.
scrollHeight
;
if
(
view
.
scrollY
+
clientHeight
>=
scrollHeight
-
clientHeight
)
{
if
(
active
)
{
active
=
false
;
scope
.
$apply
(
attr
.
windowScroll
);
}
}
else
{
active
=
true
;
}
}
view
.
addEventListener
(
'scroll'
,
onScroll
,
false
);
scope
.
$on
(
'$destroy'
,
function
()
{
view
.
removeEventListener
(
'scroll'
,
onScroll
);
});
},
};
}
src/sidebar/index.js
View file @
e1d17fe9
...
@@ -160,10 +160,6 @@ import sidebarContent from './components/sidebar-content';
...
@@ -160,10 +160,6 @@ import sidebarContent from './components/sidebar-content';
import
streamContent
from
'./components/stream-content'
;
import
streamContent
from
'./components/stream-content'
;
import
threadList
from
'./components/thread-list'
;
import
threadList
from
'./components/thread-list'
;
// Angular directives.
import
windowScrollDirective
from
'./directive/window-scroll'
;
// Services.
// Services.
import
bridgeService
from
'../shared/bridge'
;
import
bridgeService
from
'../shared/bridge'
;
...
@@ -293,7 +289,6 @@ function startAngularApp(config) {
...
@@ -293,7 +289,6 @@ function startAngularApp(config) {
.
component
(
'tagList'
,
wrapComponent
(
TagList
))
.
component
(
'tagList'
,
wrapComponent
(
TagList
))
.
component
(
'threadList'
,
threadList
)
.
component
(
'threadList'
,
threadList
)
.
component
(
'topBar'
,
wrapComponent
(
TopBar
))
.
component
(
'topBar'
,
wrapComponent
(
TopBar
))
.
directive
(
'windowScroll'
,
windowScrollDirective
)
// Register services, the store and utilities with Angular, so that
// Register services, the store and utilities with Angular, so that
// Angular components can use them.
// Angular components can use them.
...
...
src/sidebar/templates/stream-content.html
View file @
e1d17fe9
<span
window-scroll=
"vm.loadMore(20)"
>
<thread-list
<thread-list
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
on-change-collapsed=
"vm.setCollapsed(id, collapsed)"
show-document-info=
"true"
show-document-info=
"true"
thread=
"vm.rootThread()"
>
thread=
"vm.rootThread()"
>
</thread-list>
</thread-list>
</span>
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