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
c39efa6b
Commit
c39efa6b
authored
Aug 24, 2023
by
Danil Boldyrev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zoom and Pan: Resize handler
parent
fa68d66c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
6 deletions
+42
-6
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
+42
-6
No files found.
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
View file @
c39efa6b
...
...
@@ -385,6 +385,8 @@ onUiLoaded(async() => {
targetElement
.
style
.
overflow
=
"
hidden
"
;
}
targetElement
.
isZoomed
=
false
;
fixCanvas
();
targetElement
.
style
.
transform
=
`scale(
${
elemData
[
elemId
].
zoomLevel
}
) translate(
${
elemData
[
elemId
].
panX
}
px,
${
elemData
[
elemId
].
panY
}
px)`
;
...
...
@@ -479,7 +481,7 @@ onUiLoaded(async() => {
// Update the zoom level and pan position of the target element based on the values of the zoomLevel, panX and panY variables
function
updateZoom
(
newZoomLevel
,
mouseX
,
mouseY
)
{
newZoomLevel
=
Math
.
max
(
0.
5
,
Math
.
min
(
newZoomLevel
,
15
));
newZoomLevel
=
Math
.
max
(
0.
1
,
Math
.
min
(
newZoomLevel
,
15
));
elemData
[
elemId
].
panX
+=
mouseX
-
(
mouseX
*
newZoomLevel
)
/
elemData
[
elemId
].
zoomLevel
;
...
...
@@ -520,6 +522,8 @@ onUiLoaded(async() => {
zoomPosX
-
targetElement
.
getBoundingClientRect
().
left
,
zoomPosY
-
targetElement
.
getBoundingClientRect
().
top
);
targetElement
.
isZoomed
=
true
;
}
}
...
...
@@ -596,17 +600,16 @@ onUiLoaded(async() => {
`
${
elemId
}
canvas[key="interface"]`
);
if
(
isExtension
)
{
targetElement
.
style
.
overflow
=
"
visible
"
;
}
if
(
!
canvas
)
return
;
if
(
canvas
.
offsetWidth
>
862
||
isExtension
)
{
targetElement
.
style
.
width
=
(
canvas
.
offsetWidth
+
2
)
+
"
px
"
;
}
if
(
isExtension
)
{
targetElement
.
style
.
overflow
=
"
visible
"
;
}
if
(
fullScreenMode
)
{
resetZoom
();
fullScreenMode
=
false
;
...
...
@@ -867,7 +870,40 @@ onUiLoaded(async() => {
isMoving
=
false
;
};
// Checks for extension
function
checkForOutBox
()
{
const
parentElement
=
targetElement
.
closest
(
'
[id^="component-"]
'
);
if
(
parentElement
.
offsetWidth
<
targetElement
.
offsetWidth
&&
!
targetElement
.
isExpanded
)
{
resetZoom
();
targetElement
.
isExpanded
=
true
;
}
if
(
parentElement
.
offsetWidth
<
targetElement
.
offsetWidth
&&
elemData
[
elemId
].
zoomLevel
==
1
)
{
resetZoom
();
}
if
(
parentElement
.
offsetWidth
<
targetElement
.
offsetWidth
&&
targetElement
.
offsetWidth
*
elemData
[
elemId
].
zoomLevel
>
parentElement
.
offsetWidth
&&
elemData
[
elemId
].
zoomLevel
<
1
&&
!
targetElement
.
isZoomed
)
{
resetZoom
();
}
}
if
(
isExtension
)
{
targetElement
.
addEventListener
(
"
mousemove
"
,
checkForOutBox
);
}
window
.
addEventListener
(
'
resize
'
,
(
e
)
=>
{
resetZoom
();
if
(
isExtension
)
{
targetElement
.
isExpanded
=
false
;
targetElement
.
isZoomed
=
false
;
}
});
gradioApp
().
addEventListener
(
"
mousemove
"
,
handleMoveByKey
);
}
applyZoomAndPan
(
elementIDs
.
sketch
,
false
);
...
...
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