Comments (4)
Thanks for your feeback!
The topic was already on the agenda ( #13 ). I was thinking about a adding position
option, like here:
http://api.jqueryui.com/tooltip/#option-position
http://api.jqueryui.com/dialog/#option-position
(of
defaulting to parentElement).
$().contextmenu({
...
position: { my: "left top+15", at: "left bottom", collision: "flipfit" }
});
But that would not help in your use case, I guess, since event
is not known at initialization time.
Maybe we could extend this by also accepting position
to be a function?
function calcPos(event){
return {
my: "left top",
at: "left+" + event.offsetX + " top+" + event.offsetY,
of: event.target,
collision: "fit"
};
}
$().contextmenu({
...
position: calcPos
});
As an additional feature we could add a beforeShow
event, that is triggered after postioning happened.
This would allow users to call .position(...)
on the popup menu.
If you like to work on this (which I would appreciate ;-), you could create a fork and make a pull-request.
( https://help.github.com/articles/creating-a-pull-request )
Regards
Martin
from jquery-ui-contextmenu.
I have made the changes and tested them. You can not define any custom position and it will work as it did before. You can define an indirect position and it will detect that a source was not provided and use the parentTarget for the 'of' field. For example:
$().contextmenu({
...
position: { my: "left top+15", at: "left bottom", collision: "flipfit" }
});
You can position it directly like in:
$().contextmenu({
...
position: { my: "left top+15", at: "left bottom", collision: "flipfit", of: $('#anything') }
});
Or you can define a function that returns the coordinates based on the event like:
$().contextmenu({
...
position: function(event, ui) {
return {
my: "left top",
at: "left+" + event.offsetX + " top+" + event.offsetY,
of: event.target,
collision: "fit"
};
}
Let me know what you think.
- Jeff
from jquery-ui-contextmenu.
looks good!
jshint complains about minor issues, but I can also fix myself...
Would you create a pull-request?
And if you give me a name and optionally e-mail and/or url, I'll add you to the contributors list
Martin
macmartin:jquery-ui-contextmenu martin$ grunt
Running "jshint:files" (jshint) task
Linting jquery.ui-contextmenu.js...ERROR
[L33:C1] W099: Mixed spaces and tabs.
� ����preventSelect: false, // disable text selection of target
[L161:C17] W081: Too many var statements.
var posOption = this.options.position;
[L169:C18] W033: Missing semicolon.
�����}
[L174:C21] W081: Too many var statements.
var posTarget = posOption.of;
from jquery-ui-contextmenu.
Pull request done. I added the contribution information to the pull request, but I will write it here too:
My name is "Jeffrey Dean Altemus". My FOSS email is "[email protected]". My URL is "jeff.teamaltemus.net"
Since this is now complete I will close this issue.
Best Wishes,
Jeffrey Dean Altemus
from jquery-ui-contextmenu.
Related Issues (20)
- Punctuation characters in "cmd" cause JavaScript error HOT 3
- Plugin loading error reading jquery-ui property HOT 3
- How to use ContextMenu with HTML HOT 1
- Custom Icon issue HOT 1
- passing data from selected item to the select function HOT 4
- open an existing menu by left click HOT 1
- Problem running in Electron HOT 1
- Uncaught TypeError: $(...).zIndex is not a function #1 HOT 3
- jquery-migrate-3.0.0.js warning HOT 4
- What parameter in .contextmenu is used to indicate that context menu should appear on hover? HOT 1
- Context menu on hover and hide when not hover HOT 2
- Blur is fired even when I moved between context menu items HOT 1
- Contextmenu when element has no children HOT 2
- Can't create two contextmenu for the same wrapper element (document) HOT 2
- menu item title dash "-" is not showing, but showing as seperator HOT 5
- Destroy throws error HOT 2
- Live demo error HOT 1
- Checking if a context menu is opened/closed or destroyed HOT 2
- Typescript definitions? HOT 3
- disabled handler / issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-ui-contextmenu.