Adjust scroll

master
Matthew 6 years ago
parent 1bc33d3276
commit 62ab2cf10f
  1. 14
      core/browser.py
  2. 14
      core/js/get_markers.js
  3. 21
      core/js/goto_marker.js

@ -223,28 +223,28 @@ class BrowserView(QWebEngineView):
return self.web_page.executeJavaScript(js)
def scroll_left(self):
self.eval_js("window.scrollBy(-50, 0)")
self.eval_js("document.scrollingElement.scrollBy(-35, 0)")
def scroll_right(self):
self.eval_js("window.scrollBy(50, 0)")
self.eval_js("document.scrollingElement.scrollBy(35, 0)")
def scroll_up(self):
self.eval_js("window.scrollBy(0, 50)")
self.eval_js("document.scrollingElement.scrollBy(0, 50)")
def scroll_down(self):
self.eval_js("window.scrollBy(0, -50)")
self.eval_js("document.scrollingElement.scrollBy(0, -50)")
def scroll_up_page(self):
self.eval_js("window.scrollBy({left: 0, top: document.documentElement.clientHeight, behavior: 'smooth'})")
self.eval_js("document.scrollingElement.scrollBy({left: 0, top: window.innerHeight/2, behavior: 'smooth'})")
def scroll_down_page(self):
self.eval_js("window.scrollBy({left: 0, top: -document.documentElement.clientHeight, behavior: 'smooth'})")
self.eval_js("document.scrollingElement.scrollBy({left: 0, top: -window.innerHeight/2, behavior: 'smooth'})")
def scroll_to_begin(self):
self.eval_js("window.scrollTo({left: 0, top: 0, behavior: 'smooth'})")
def scroll_to_bottom(self):
self.eval_js("window.scrollBy({left: 0, top: document.body.scrollHeight, behavior: 'smooth'})")
self.eval_js("document.scrollingElement.scrollBy({left: 0, top: document.body.scrollHeight, behavior: 'smooth'})")
def refresh_page(self):
self.reload()

@ -152,15 +152,15 @@ z-index: 100000;\
let validRects = [];
addElementToRects(validRects, document.links); // collect links
addElementToRects(validRects, document.querySelectorAll('a')); // collect a tag without href
addElementToRects(validRects, document.querySelectorAll('input')); // collect inputs
addElementToRects(validRects, document.querySelectorAll('button')); // collect buttons
addElementToRects(validRects, document.querySelectorAll('[class*="btn"]')); // collect btn buttons
addElementToRects(validRects, document.querySelectorAll('a')); // collect <a> without href
addElementToRects(validRects, document.querySelectorAll('input')); // collect <input>
addElementToRects(validRects, document.querySelectorAll('button')); // collect <button>
addElementToRects(validRects, document.querySelectorAll('[class*="btn"]')); // collect class=btn buttons
addElementToRects(validRects, document.querySelectorAll('[aria-haspopup]')); // collect menu buttons
addElementToRects(validRects, document.querySelectorAll('[role="button"]')); // collect role="button"
addElementToRects(validRects, document.querySelectorAll('textarea')); // collect textarea
addElementToRects(validRects, document.querySelectorAll('select')); // collect select
addElementToRects(validRects, document.querySelectorAll('summary')); // collect summary
addElementToRects(validRects, document.querySelectorAll('textarea')); // collect <textarea>
addElementToRects(validRects, document.querySelectorAll('select')); // collect <select>
addElementToRects(validRects, document.querySelectorAll('summary')); // collect <summary>
let body = document.querySelector('body');
let markerContainer = document.createElement('div');

@ -1,14 +1,4 @@
(function() {
let key = "%1";
let markers = document.querySelectorAll('.eaf-marker');
let match;
for(let i = 0; i < markers.length; i++) {
if(markers[i].id === key.toUpperCase()) {
match = markers[i];
break;
}
}
function moveCursorToEnd(el) {
if (typeof el.selectionStart == "number") {
el.selectionStart = el.selectionEnd = el.value.length;
@ -20,9 +10,20 @@
}
}
let key = "%1";
let markers = document.querySelectorAll('.eaf-marker');
let match;
for(let i = 0; i < markers.length; i++) {
if(markers[i].id === key.toUpperCase()) {
match = markers[i];
break;
}
}
if(match != undefined){
let selector = match.getAttribute('pointed-link');
let link = document.querySelector(selector);
if(link.nodeName.toLowerCase() === 'select'){
link.focus();
}else if(link.nodeName.toLowerCase() === 'input' ||

Loading…
Cancel
Save