Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
ed01d2ee
Commit
ed01d2ee
authored
Aug 10, 2023
by
Danil Boldyrev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a another fix, a different approach
parent
4a64d340
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
+21
-2
No files found.
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
View file @
ed01d2ee
...
@@ -12,6 +12,7 @@ onUiLoaded(async() => {
...
@@ -12,6 +12,7 @@ onUiLoaded(async() => {
"
Sketch
"
:
elementIDs
.
sketch
"
Sketch
"
:
elementIDs
.
sketch
};
};
// Helper functions
// Helper functions
// Get active tab
// Get active tab
function
getActiveTab
(
elements
,
all
=
false
)
{
function
getActiveTab
(
elements
,
all
=
false
)
{
...
@@ -657,17 +658,20 @@ onUiLoaded(async() => {
...
@@ -657,17 +658,20 @@ onUiLoaded(async() => {
// Simulation of the function to put a long image into the screen.
// Simulation of the function to put a long image into the screen.
// We detect if an image has a scroll bar or not, make a fullscreen to reveal the image, then reduce it to fit into the element.
// We detect if an image has a scroll bar or not, make a fullscreen to reveal the image, then reduce it to fit into the element.
// We hide the image and show it to the user when it is ready.
// We hide the image and show it to the user when it is ready.
function
autoExpand
(
e
)
{
targetElement
.
isExpanded
=
false
;
function
autoExpand
()
{
const
canvas
=
document
.
querySelector
(
`
${
elemId
}
canvas[key="interface"]`
);
const
canvas
=
document
.
querySelector
(
`
${
elemId
}
canvas[key="interface"]`
);
const
isMainTab
=
activeElement
===
elementIDs
.
inpaint
||
activeElement
===
elementIDs
.
inpaintSketch
||
activeElement
===
elementIDs
.
sketch
;
const
isMainTab
=
activeElement
===
elementIDs
.
inpaint
||
activeElement
===
elementIDs
.
inpaintSketch
||
activeElement
===
elementIDs
.
sketch
;
if
(
canvas
&&
isMainTab
)
{
if
(
canvas
&&
isMainTab
)
{
if
(
hasHorizontalScrollbar
(
targetElement
))
{
if
(
hasHorizontalScrollbar
(
targetElement
)
&&
targetElement
.
isExpanded
===
false
)
{
targetElement
.
style
.
visibility
=
"
hidden
"
;
targetElement
.
style
.
visibility
=
"
hidden
"
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
fitToScreen
();
fitToScreen
();
resetZoom
();
resetZoom
();
targetElement
.
style
.
visibility
=
"
visible
"
;
targetElement
.
style
.
visibility
=
"
visible
"
;
targetElement
.
isExpanded
=
true
;
},
10
);
},
10
);
}
}
}
}
...
@@ -675,9 +679,24 @@ onUiLoaded(async() => {
...
@@ -675,9 +679,24 @@ onUiLoaded(async() => {
targetElement
.
addEventListener
(
"
mousemove
"
,
getMousePosition
);
targetElement
.
addEventListener
(
"
mousemove
"
,
getMousePosition
);
//observers
// Creating an observer with a callback function to handle DOM changes
const
observer
=
new
MutationObserver
((
mutationsList
,
observer
)
=>
{
for
(
let
mutation
of
mutationsList
)
{
// If the style attribute of the canvas has changed, by observation it happens only when the picture changes
if
(
mutation
.
type
===
'
attributes
'
&&
mutation
.
attributeName
===
'
style
'
&&
mutation
.
target
.
tagName
.
toLowerCase
()
===
'
canvas
'
)
{
targetElement
.
isExpanded
=
false
;
setTimeout
(
resetZoom
,
10
);
}
}
});
// Apply auto expand if enabled
// Apply auto expand if enabled
if
(
hotkeysConfig
.
canvas_auto_expand
)
{
if
(
hotkeysConfig
.
canvas_auto_expand
)
{
targetElement
.
addEventListener
(
"
mousemove
"
,
autoExpand
);
targetElement
.
addEventListener
(
"
mousemove
"
,
autoExpand
);
// Set up an observer to track attribute changes
observer
.
observe
(
targetElement
,
{
attributes
:
true
,
childList
:
true
,
subtree
:
true
});
}
}
// Handle events only inside the targetElement
// Handle events only inside the targetElement
...
...
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