mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
223 lines
7.4 KiB
HTML
223 lines
7.4 KiB
HTML
<!doctype html>
|
|
<!--
|
|
@license
|
|
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
|
Code distributed by Google as part of the polymer project is also
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
|
-->
|
|
<html id="html">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>iron-scroll-threshold test</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
|
|
|
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
<script src="../../web-component-tester/browser.js"></script>
|
|
|
|
<link rel="import" href="../iron-scroll-threshold.html">
|
|
|
|
<style>
|
|
#scrollingRegion {
|
|
width: 200px;
|
|
height: 200px;
|
|
overflow: auto;
|
|
background: green;
|
|
}
|
|
.content {
|
|
height: 2000px;
|
|
width: 2px;
|
|
background-color: gray;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<test-fixture id="trivialScrollThreshold">
|
|
<template>
|
|
<iron-scroll-threshold id="scrollingRegion">
|
|
<div class="content"></div>
|
|
</iron-scroll-threshold>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<test-fixture id="trivialDocumentScrolling">
|
|
<template>
|
|
<iron-scroll-threshold scroll-target="html">
|
|
<div class="content"></div>
|
|
</iron-scroll-threshold>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
|
|
suite('basic features', function() {
|
|
var scrollThreshold;
|
|
|
|
setup(function() {
|
|
scrollThreshold = fixture('trivialScrollThreshold');
|
|
});
|
|
|
|
teardown(function() {
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollTop = 0;
|
|
});
|
|
|
|
test('default', function() {
|
|
assert.equal(scrollThreshold._defaultScrollTarget, scrollThreshold, '_defaultScrollTarget');
|
|
assert.equal(scrollThreshold.scrollTarget, scrollThreshold, 'scrollTarget');
|
|
assert.equal(scrollThreshold.upperThreshold, 100, 'upperThreshold');
|
|
assert.equal(scrollThreshold.lowerThreshold, 100, 'lowerThreshold');
|
|
assert.equal(scrollThreshold.horizontal, false, 'horizontal');
|
|
assert.equal(window.getComputedStyle(scrollThreshold.scrollTarget).overflow, 'auto', 'overflow');
|
|
});
|
|
|
|
test('upper-threshold event', function(done) {
|
|
flush(function() {
|
|
scrollThreshold.addEventListener('upper-threshold', function() {
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
done();
|
|
});
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollTop = scrollThreshold._scrollTop + 1;
|
|
});
|
|
});
|
|
|
|
test('lower-threshold event', function(done) {
|
|
flush(function() {
|
|
scrollThreshold.addEventListener('lower-threshold', function() {
|
|
assert.isTrue(scrollThreshold.lowerTriggered);
|
|
done();
|
|
});
|
|
scrollThreshold._scrollTop = scrollThreshold.scrollTarget.scrollHeight;
|
|
});
|
|
});
|
|
|
|
test('clearTriggers', function(done) {
|
|
flush(function() {
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
scrollThreshold.clearTriggers();
|
|
assert.isFalse(scrollThreshold.upperTriggered);
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('checkScrollThesholds', function(done) {
|
|
flush(function() {
|
|
scrollThreshold._scrollTop = scrollThreshold.scrollTarget.scrollHeight;
|
|
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'check assumption');
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.lowerTriggered, 'check triggers');
|
|
scrollThreshold.clearTriggers();
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'reset triggers');
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('horizontal', function(done) {
|
|
scrollThreshold.horizontal = true;
|
|
flush(function() {
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollLeft = scrollThreshold.scrollTarget.scrollWidth;
|
|
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'check assumption');
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.lowerTriggered, 'check lowerTriggered');
|
|
scrollThreshold._scrollLeft = 0;
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.upperTriggered, 'upperTriggered');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
suite('document scroll', function() {
|
|
var scrollThreshold;
|
|
|
|
setup(function() {
|
|
scrollThreshold = fixture('trivialDocumentScrolling');
|
|
});
|
|
|
|
teardown(function() {
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollTop = 0;
|
|
});
|
|
|
|
test('default', function() {
|
|
assert.equal(scrollThreshold.scrollTarget, scrollThreshold._doc, 'scrollTarget');
|
|
assert.equal(scrollThreshold.upperThreshold, 100, 'upperThreshold');
|
|
assert.equal(scrollThreshold.lowerThreshold, 100, 'lowerThreshold');
|
|
assert.equal(scrollThreshold.horizontal, false, 'horizontal');
|
|
});
|
|
|
|
test('upper-threshold event', function(done) {
|
|
flush(function() {
|
|
scrollThreshold.addEventListener('upper-threshold', function() {
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
done();
|
|
});
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollTop = scrollThreshold._scrollTop + 1;
|
|
});
|
|
});
|
|
|
|
test('lower-threshold event', function(done) {
|
|
flush(function() {
|
|
scrollThreshold.addEventListener('lower-threshold', function() {
|
|
assert.isTrue(scrollThreshold.lowerTriggered);
|
|
done();
|
|
});
|
|
scrollThreshold._scrollTop = scrollThreshold.scrollTarget.scrollHeight;
|
|
});
|
|
});
|
|
|
|
test('clearTriggers', function(done) {
|
|
flush(function() {
|
|
assert.isTrue(scrollThreshold.upperTriggered);
|
|
scrollThreshold.clearTriggers();
|
|
assert.isFalse(scrollThreshold.upperTriggered);
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('checkScrollThesholds', function(done) {
|
|
flush(function() {
|
|
scrollThreshold._scrollTop = scrollThreshold.scrollTarget.scrollHeight;
|
|
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'check assumption');
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.lowerTriggered, 'check triggers');
|
|
scrollThreshold.clearTriggers();
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'reset triggers');
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('horizontal', function(done) {
|
|
scrollThreshold.horizontal = true;
|
|
flush(function() {
|
|
scrollThreshold.clearTriggers();
|
|
scrollThreshold._scrollLeft = scrollThreshold.scrollTarget.scrollWidth;
|
|
|
|
assert.isFalse(scrollThreshold.lowerTriggered, 'check assumption');
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.lowerTriggered, 'check lowerTriggered');
|
|
scrollThreshold._scrollLeft = 0;
|
|
scrollThreshold.checkScrollThesholds();
|
|
assert.isTrue(scrollThreshold.upperTriggered, 'upperTriggered');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|