playground/client: Fix console auto scroll.
scrollHeight and clientHeight rounding inaccuracy.
Firefox race condition.
Change-Id: I39ecc32eb698c958318587592f7c7a5b8e14afd8
diff --git a/client/src/javascript/playground.js b/client/src/javascript/playground.js
index 01513fb..9e8ece0 100644
--- a/client/src/javascript/playground.js
+++ b/client/src/javascript/playground.js
@@ -286,21 +286,27 @@
// user scrolling up.
function ScrollHandle(scrollState) {
this.scrollState_ = scrollState;
+ this.enableScrollUpdates_ = false;
}
ScrollHandle.prototype.hook = function(elem, propname) {
- var scrollState = this.scrollState_;
+ var that = this;
process.nextTick(function() {
- if (scrollState.bottom) {
+ if (that.scrollState_.bottom) {
elem.scrollTop = elem.scrollHeight - elem.clientHeight;
}
+ that.enableScrollUpdates_ = true;
});
};
ScrollHandle.prototype.update = function(ev) {
- var elem = ev.currentTarget;
- this.scrollState_.bottom =
- elem.scrollTop === elem.scrollHeight - elem.clientHeight;
+ var el = ev.currentTarget;
+ if (this.enableScrollUpdates_) {
+ // scrollHeight and clientHeight are rounded to an integer, so we need to
+ // compare fuzzily.
+ this.scrollState_.bottom =
+ Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) <= 2.01;
+ }
};
Playground.prototype.renderConsole_ = function(state) {
diff --git a/go/src/playground/compilerd/storage.go b/go/src/playground/compilerd/storage.go
index 1605182..0fb6b3e 100644
--- a/go/src/playground/compilerd/storage.go
+++ b/go/src/playground/compilerd/storage.go
@@ -25,7 +25,7 @@
)
var (
- // Path to SQL configuration file, as described in playground/lib/mysql.go.
+ // Path to SQL configuration file, as described in v.io/lib/dbutil/mysql.go.
sqlConf = flag.String("sqlconf", "", "Path to SQL configuration file. If empty, load and save requests are disabled. "+dbutil.SqlConfigFileDescription)
// Testing parameter, use default value for production.