Skip to content
Snippets Groups Projects
Commit 587540b5 authored by Malte Neugebauer's avatar Malte Neugebauer
Browse files

Function tutorialFocusElement optimized for WHS-Moodle.

parent 00e35ba7
Branches
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
///START AL QUIZ SCRIPT///
class QuestionGroup {
constructor(id, description, Questions, nextGroup) {
......@@ -956,15 +957,34 @@ function tutorialFocusElement(elem) {
userFocusBottom.classList.add("user-focus", "hide-bottom");
userFocusBottom.onclick = removeTutorialFocus;
let offset = 0;
let pageHeight = 0;
let bodyNode = null;
let pageElementWHS = document.getElementById("page");
if(!pageElementWHS) {
//probably not in moodle of university of applied sciences Gelsenkirchen, Germany
offset = window.pageYOffset;
pageHeight = document.documentElement.scrollHeight;
bodyNode = document.body;
}
else {
//probably in moodle of university of applied sciences Gelsenkirchen, Germany
let navbar = document.querySelector("nav");
offset = pageElementWHS.scrollTop - (!navbar ? 0 : navbar.getBoundingClientRect().height);
pageHeight = pageElementWHS.scrollHeight;
console.log("we are in WHS-Moodle, offset: "+offset+", pageHeight: "+pageHeight);
bodyNode = pageElementWHS;
}
let position = elem.getBoundingClientRect(elem);
userFocusTop.style.height=Math.ceil(position.top+window.pageYOffset-20)+"px";
userFocusTop.style.height=Math.ceil(position.top+offset-20)+"px";
let pageHeight = document.documentElement.scrollHeight;
userFocusBottom.style.top = Math.ceil(position.bottom+window.pageYOffset+20)+"px";
userFocusBottom.style.height=Math.ceil(pageHeight-(position.bottom+window.pageYOffset+20))+"px";
userFocusBottom.style.top = Math.ceil(position.bottom+offset+20)+"px";
userFocusBottom.style.height=Math.ceil(pageHeight-(position.bottom+offset+20))+"px";
console.log(userFocusTop.style.height,userFocusBottom.style.top,userFocusBottom.style.height);
document.body.appendChild(userFocusTop);
document.body.appendChild(userFocusBottom);
bodyNode.appendChild(userFocusTop);
bodyNode.appendChild(userFocusBottom);
if(supportsSmoothScrolling() == true) {
elem.scrollIntoView({behavior:"smooth", block:"center", inline:"center"});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment