fix documentation scroll

This commit is contained in:
SBD
2024-07-11 15:14:51 +03:00
parent 1aeb83d571
commit aafa989501
6 changed files with 236 additions and 21 deletions

View File

@@ -12,7 +12,108 @@ $(document).ready(function (){
resize_iframe()
}
}
if (getInfoAboutUser()[0] === 'laptop' || getInfoAboutUser()[0] === 'mobile'){
setInfInCurtainDocumentationMobile()
setButtonOpenMobileDocCurtain()
}
})
function setButtonOpenMobileDocCurtain () {
let $content = $('.content_part_tree_els')
let $cont = document.createElement("div")
let $txt = document.createElement("div")
let $picture = document.createElement("picture")
let $source = document.createElement("source")
let $img = document.createElement("img")
$cont.classList.add("container_open_doc_curtain")
$txt.innerHTML = context_txt_translated
$txt.setAttribute("onclick",'openDocCurtainMobile()')
$txt.classList.add("container_open_doc_curtain_txt")
$picture.classList.add("container_open_doc_curtain_picture")
$source.srcset = '/static/images/arrow_open_documentation_curtain.svg'
$img.classList.add("container_open_doc_curtain_img")
$img.src = '/static/images/arrow_open_documentation_curtain.svg'
$cont.appendChild($txt)
$cont.appendChild($picture)
$picture.appendChild($source)
$picture.appendChild($img)
$($cont).insertBefore($content)
}
function setInfInCurtainDocumentationMobile () {
let $doc_vers = $(".documentation_version")
let $container = document.createElement("div")
let $txt = document.createElement("div")
let $picture = document.createElement("picture")
let $source = document.createElement("source")
let $img = document.createElement("img")
$container.classList.add("container_top_txt_curtain_documentation")
$picture.classList.add("top_picture_curtain_documentation")
$txt.innerHTML = context_txt_translated
$txt.classList.add("top_txt_curtain_documentation")
$source.srcset = '/static/images/cross.svg'
$img.src = '/static/images/cross.svg'
$container.appendChild($txt)
$container.appendChild($picture)
$picture.appendChild($source)
$picture.setAttribute("onclick","closeDocCurtainMobile()")
$picture.appendChild($img)
$($container).insertBefore($doc_vers)
}
function openDocCurtainMobile () {
let $curtain = $(".left_curtain_documentation")
let $block_overlay = $(".block_overlay")
$curtain.css({left:0})
$block_overlay.removeClass("hide")
$block_overlay.addClass("show")
$block_overlay.css({zIndex:10000})
}
function closeDocCurtainMobile () {
let $curtain = $(".left_curtain_documentation")
let $block_overlay = $(".block_overlay")
$curtain.css({left:'-320px'})
$block_overlay.addClass("hide")
$block_overlay.removeClass("show")
$block_overlay.css({zIndex:101})
}
autoplayInterval = null
function resize_iframe () {
@@ -466,25 +567,27 @@ function showContentPartTree (el) {
}
let waitingTop = null
$(window).scroll(function (){
if (window.location.href.includes("docs")){
let $curtain = $(".left_curtain_documentation")
let scroll = $(window)[0].scrollY
if (scroll === 0){
waitingTop = $(".left_curtain_documentation")[0].getBoundingClientRect().top - 172
}
let $new_curtain = $($curtain[1])
if (!$curtain[1] && waitingTop){
$new_curtain = $curtain.clone()
$new_curtain.insertAfter($curtain)
}
if (scroll >= waitingTop && waitingTop){
$new_curtain.css({position:'fixed',top: 166})
$($curtain[0]).css({opacity:0})
} else if (scroll < waitingTop && waitingTop) {
$new_curtain.remove()
$($curtain[0]).css({opacity:1})
} else if (!waitingTop){
waitingTop = $(".left_curtain_documentation")[0].getBoundingClientRect().top - 172
if (getInfoAboutUser()[0] !== 'laptop' && getInfoAboutUser()[0] !== 'mobile'){
if (window.location.href.includes("docs")){
let $curtain = $(".left_curtain_documentation")
let scroll = $(window)[0].scrollY
if (scroll === 0){
waitingTop = $(".left_curtain_documentation")[0].getBoundingClientRect().top - 172
}
let $new_curtain = $($curtain[1])
if (!$curtain[1] && waitingTop){
$new_curtain = $curtain.clone()
$new_curtain.insertAfter($curtain)
}
if (scroll >= waitingTop && waitingTop){
$new_curtain.css({position:'fixed',top: 166})
$($curtain[0]).css({opacity:0})
} else if (scroll < waitingTop && waitingTop) {
$new_curtain.remove()
$($curtain[0]).css({opacity:1})
} else if (!waitingTop){
waitingTop = $(".left_curtain_documentation")[0].getBoundingClientRect().top - 172
}
}
}
})