Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
c4067c56
Commit
c4067c56
authored
Nov 30, 2022
by
Suffocate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore scroll position on page if giving active element focus changes it
parent
4b3c5bc2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
progressbar.js
javascript/progressbar.js
+14
-2
No files found.
javascript/progressbar.js
View file @
c4067c56
...
@@ -92,14 +92,26 @@ function check_gallery(id_gallery){
...
@@ -92,14 +92,26 @@ function check_gallery(id_gallery){
if
(
prevSelectedIndex
!==
-
1
&&
galleryButtons
.
length
>
prevSelectedIndex
&&
!
galleryBtnSelected
)
{
if
(
prevSelectedIndex
!==
-
1
&&
galleryButtons
.
length
>
prevSelectedIndex
&&
!
galleryBtnSelected
)
{
// automatically re-open previously selected index (if exists)
// automatically re-open previously selected index (if exists)
activeElement
=
gradioApp
().
activeElement
;
activeElement
=
gradioApp
().
activeElement
;
let
scrollX
=
window
.
scrollX
;
let
scrollY
=
window
.
scrollY
;
galleryButtons
[
prevSelectedIndex
].
click
();
galleryButtons
[
prevSelectedIndex
].
click
();
showGalleryImage
();
showGalleryImage
();
// When the gallery button is clicked, it gains focus and scrolls itself into view
// We need to scroll back to the previous position
setTimeout
(
function
(){
window
.
scrollTo
(
scrollX
,
scrollY
);
},
50
);
if
(
activeElement
){
if
(
activeElement
){
// i fought this for about an hour; i don't know why the focus is lost or why this helps recover it
// i fought this for about an hour; i don't know why the focus is lost or why this helps recover it
// if somenoe has a better solution please by all means
// if someone has a better solution please by all means
setTimeout
(
function
()
{
activeElement
.
focus
()
},
1
);
setTimeout
(
function
(){
activeElement
.
focus
({
preventScroll
:
true
// Refocus the element that was focused before the gallery was opened without scrolling to it
})
},
1
);
}
}
}
}
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment