Center scrolled view

This commit is contained in:
Kenox 2022-11-03 18:52:06 +01:00
commit 440b6e75bf
3 changed files with 14 additions and 11 deletions

View file

@ -229,15 +229,6 @@ haste.prototype.loadDocument = function(key) {
_this.$textarea.val('').hide(); _this.$textarea.val('').hide();
_this.$box.show().focus(); _this.$box.show().focus();
_this.addLineNumbers(ret.lineCount); _this.addLineNumbers(ret.lineCount);
if(window.location.hash) {
const hash = window.location.hash.substring(1);
highlightLine(hash)
document.getElementsByClassName("highlight")[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
} }
else { else {
_this.newDocument(); _this.newDocument();

File diff suppressed because one or more lines are too long

View file

@ -19,7 +19,19 @@
var handlePop = function(evt) { var handlePop = function(evt) {
var path = evt.target.location.pathname; var path = evt.target.location.pathname;
if (path === '/') { app.newDocument(true); } if (path === '/') { app.newDocument(true); }
else { app.loadDocument(path.substring(1, path.length)); } else { app.loadDocument(path.substring(1, path.length));
}
if(window.location.hash) {
const hash = window.location.hash.substring(1);
highlightLine(hash)
document.getElementsByClassName("highlight")[0].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
document.getElementById("box").scrollLeft = 0
}
}; };
// Set up the pop state to handle loads, skipping the first load // Set up the pop state to handle loads, skipping the first load
// to make chrome behave like others: // to make chrome behave like others: