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
74b1fc62
Commit
74b1fc62
authored
Jun 08, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jun 08, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15682 from light-and-ray/two_fingers_press_to_open_context_menu
two fingers press to open context menu
parents
4aebfe98
dbda59e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
31 deletions
+18
-31
javascript/contextMenus.js
javascript/contextMenus.js
+18
-31
No files found.
javascript/contextMenus.js
View file @
74b1fc62
...
...
@@ -8,9 +8,6 @@ var contextMenuInit = function() {
};
function
showContextMenu
(
event
,
element
,
menuEntries
)
{
let
posx
=
event
.
clientX
+
document
.
body
.
scrollLeft
+
document
.
documentElement
.
scrollLeft
;
let
posy
=
event
.
clientY
+
document
.
body
.
scrollTop
+
document
.
documentElement
.
scrollTop
;
let
oldMenu
=
gradioApp
().
querySelector
(
'
#context-menu
'
);
if
(
oldMenu
)
{
oldMenu
.
remove
();
...
...
@@ -23,10 +20,8 @@ var contextMenuInit = function() {
contextMenu
.
style
.
background
=
baseStyle
.
background
;
contextMenu
.
style
.
color
=
baseStyle
.
color
;
contextMenu
.
style
.
fontFamily
=
baseStyle
.
fontFamily
;
contextMenu
.
style
.
top
=
posy
+
'
px
'
;
contextMenu
.
style
.
left
=
posx
+
'
px
'
;
contextMenu
.
style
.
top
=
event
.
pageY
+
'
px
'
;
contextMenu
.
style
.
left
=
event
.
pageX
+
'
px
'
;
const
contextMenuList
=
document
.
createElement
(
'
ul
'
);
contextMenuList
.
className
=
'
context-menu-items
'
;
...
...
@@ -43,21 +38,6 @@ var contextMenuInit = function() {
});
gradioApp
().
appendChild
(
contextMenu
);
let
menuWidth
=
contextMenu
.
offsetWidth
+
4
;
let
menuHeight
=
contextMenu
.
offsetHeight
+
4
;
let
windowWidth
=
window
.
innerWidth
;
let
windowHeight
=
window
.
innerHeight
;
if
((
windowWidth
-
posx
)
<
menuWidth
)
{
contextMenu
.
style
.
left
=
windowWidth
-
menuWidth
+
"
px
"
;
}
if
((
windowHeight
-
posy
)
<
menuHeight
)
{
contextMenu
.
style
.
top
=
windowHeight
-
menuHeight
+
"
px
"
;
}
}
function
appendContextMenuOption
(
targetElementSelector
,
entryName
,
entryFunction
)
{
...
...
@@ -107,16 +87,23 @@ var contextMenuInit = function() {
oldMenu
.
remove
();
}
});
gradioApp
().
addEventListener
(
"
contextmenu
"
,
function
(
e
)
{
let
oldMenu
=
gradioApp
().
querySelector
(
'
#context-menu
'
);
if
(
oldMenu
)
{
oldMenu
.
remove
();
}
menuSpecs
.
forEach
(
function
(
v
,
k
)
{
if
(
e
.
composedPath
()[
0
].
matches
(
k
))
{
showContextMenu
(
e
,
e
.
composedPath
()[
0
],
v
);
e
.
preventDefault
();
[
'
contextmenu
'
,
'
touchstart
'
].
forEach
((
eventType
)
=>
{
gradioApp
().
addEventListener
(
eventType
,
function
(
e
)
{
let
ev
=
e
;
if
(
eventType
.
startsWith
(
'
touch
'
))
{
if
(
e
.
touches
.
length
!==
2
)
return
;
ev
=
e
.
touches
[
0
];
}
let
oldMenu
=
gradioApp
().
querySelector
(
'
#context-menu
'
);
if
(
oldMenu
)
{
oldMenu
.
remove
();
}
menuSpecs
.
forEach
(
function
(
v
,
k
)
{
if
(
e
.
composedPath
()[
0
].
matches
(
k
))
{
showContextMenu
(
ev
,
e
.
composedPath
()[
0
],
v
);
e
.
preventDefault
();
}
});
});
});
eventListenerApplied
=
true
;
...
...
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