[Pkg-javascript-commits] [pdf.js] 53/106: Implement an option to disable automatic scrolling
David Prévot
taffit at moszumanska.debian.org
Sat Jun 20 21:34:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit e02ab9fb79d0c51e46f85279bd2a11cfb2f042d3
Author: Tim van der Meij <timvandermeij at gmail.com>
Date: Fri May 15 19:58:34 2015 +0200
Implement an option to disable automatic scrolling
This adds a checkbox with which one can disable scrolling, for example to look back at output during testing. Note that the styles are inline because the test runner removes all <style> elements for each test.
---
test/driver.js | 11 +++++++----
test/test_slave.html | 9 +++++++--
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/test/driver.js b/test/driver.js
index c67449b..5ffe556 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -96,9 +96,11 @@ var SimpleTextLayerBuilder = (function SimpleTextLayerBuilderClosure() {
/**
* @typedef {Object} DriverOptions
- * @property {HTMLPreElement} output - Container for all output messages.
* @property {HTMLSpanElement} inflight - Field displaying the number of
* inflight requests.
+ * @property {HTMLInputElement} disableScrolling - Checkbox to disable
+ * automatic scrolling of the output container.
+ * @property {HTMLPreElement} output - Container for all output messages.
* @property {HTMLDivElement} end - Container for a completion message.
*/
@@ -118,8 +120,9 @@ var Driver = (function DriverClosure() {
PDFJS.enableStats = true;
// Set the passed options
- this.output = options.output;
this.inflight = options.inflight;
+ this.disableScrolling = options.disableScrolling;
+ this.output = options.output;
this.end = options.end;
// Set parameters from the query string
@@ -410,9 +413,9 @@ var Driver = (function DriverClosure() {
this.output.textContent += message;
}
- if (message.lastIndexOf('\n') >= 0) {
+ if (message.lastIndexOf('\n') >= 0 && !this.disableScrolling.checked) {
// Scroll to the bottom of the page
- window.scrollTo(0, document.body.scrollHeight);
+ this.output.scrollTop = this.output.scrollHeight;
}
},
diff --git a/test/test_slave.html b/test/test_slave.html
index 3a84bd3..8a78e97 100644
--- a/test/test_slave.html
+++ b/test/test_slave.html
@@ -29,14 +29,19 @@ limitations under the License.
<script src="driver.js"></script>
</head>
<body>
- <pre id="output"></pre>
<p>Inflight requests: <span id="inflight"></span></p>
+ <p>
+ <input type="checkbox" id="disableScrolling">
+ <label for="disableScrolling">Disable automatic scrolling</label>
+ </p>
+ <pre id="output" style="max-height: 800px; overflow-y: scroll;"></pre>
<div id="end"></div>
</body>
<script>
var driver = new Driver({
- output: document.getElementById('output'),
+ disableScrolling: document.getElementById('disableScrolling'),
inflight: document.getElementById('inflight'),
+ output: document.getElementById('output'),
end: document.getElementById('end')
});
driver.run();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list