-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make small object on top of active one selectable with preserve object stacking true #3095
Comments
This problem does not happen in <= 1.6.2 version |
I have some difficulties trying to accomodate any selecting situatuon. That involves object selected is under another, but is bigger, or smaller than the covering one. Or when the selecte object has just one handle under another object. If you think to have a logic that fix all necessity please illustrate it and help me. |
This does not really seem like the same issue that you just closed for me, but here are my 5 cents anyways. This order should be the most logical one: |
I would say the first object to get the click event should keep it. If clicked within its visible boundaries an object get selected. Same logic applies to handles an handle should get the click event as if the object. An handle in front of an object should get the click and keep it. On Sun, Jul 10, 2016 at 11:02 PM +0200, "Andrea Bogazzi" notifications@github.com wrote: I have some difficulties trying to accomodate any selecting situatuon. That involves object selected is under another, but is bigger, or smaller than the covering one. Or when the selecte object has just one handle under another object. If you think to have a logic that fix all necessity please illustrate it and help me. — |
BTw, my issue occurs on earlier version as well, not just 1.6.2 as for the OP. In our application we changed how selection is handled and smaller objects are always selected regardless of whats above it, like this:
This is of course not a complete solution, but i think the concept is much more logical for most cases. To this it also needs to be added a fix for always selecting widgets first, but i have no clue on how that stuff works. |
-Widgets should always have priority. Done with #3111 |
With the new version of fabricjs : https://jsfiddle.net/ecvctazk/5/ It's better But we must unselect objects before the select object |
The idea for now would be this: findTarget: function (e, skipGroup) {
if (this.skipTargetFind) {
return;
}
var ignoreZoom = true,
pointer = this.getPointer(e, ignoreZoom),
activeGroup = this.getActiveGroup(),
activeObject = this.getActiveObject(),
firstTarget, secondTarget;
this.targets = [ ];
// first check current group (if one exists)
// active group does not check sub targets like normal groups.
// if active group just exits.
if (activeGroup && !skipGroup && this._checkTarget(pointer, activeGroup)) {
firstTarget = activeGroup;
}
// this will take care of subTargets of activeObject if activeObject is a group
if (activeObject && this._searchPossibleTargets([activeObject], pointer) === activeObject) {
firstTarget = activeObject;
}
if (!this.preserveObjectStacking && firstTarget) {
return firstTarget;
}
var secondTarget = this._searchPossibleTargets(this._objects, pointer, firstTarget);
if (secondTarget && secondTarget !== firstTarget) {
if (secondTarget.area() < firstTarget.area() / 2) {
firstTarget = secondTarget;
}
}
this._fireOverOutEvents(firstTarget, e);
return firstTarget;
}, with searchPossibleTargets _searchPossibleTargets: function(objects, pointer, firstTarget) {
// Cache all targets where their bounding box contains point.
var target, i = objects.length, normalizedPointer, subTarget, _target
// Do not check for currently grouped objects, since we check the parent group itself.
// untill we call this function specifically to search inside the activeGroup
while (i--) {
_target = objects[i];
if (_target !== firstTarget && this._checkTarget(pointer, _target)) {
target = _target;
if (target.type === 'group' && target.subTargetCheck) {
normalizedPointer = this._normalizePointer(target, pointer);
subTarget = this._searchPossibleTargets(target._objects, normalizedPointer);
subTarget && this.targets.push(subTarget);
}
break;
}
}
return target;
}, We check for activeGroup or activeObject. If activeObject is a group (not activeGroup) we perform subTargetCheck. If we are in preserveObjectStacking, let's see if there is another target in the way that is not activeObject. If there is and is smaller of the current object ( .area() still to create ) then that may be the real target. ( ops need to check also zIndex ). What do you think? |
To check better we are not firing out events for active target or active group now. |
Sounds sane to me, a bit hard to tell without testing though. But I think it will work fine. |
Like this : https://jsfiddle.net/ecvctazk/9/ ? |
That fiddle does not work well at all for me. (tested on my phone) |
Yes, a problem with : |
Try this : https://jsfiddle.net/ecvctazk/15/ I disable area |
It's ok But with multiple object selection there are some problems |
A solution : https://jsfiddle.net/ecvctazk/33/ |
Now nothing works at all. |
mine was an idea, i did not get ready the .area function, nor i m sure is a good idea. it can be an improvement over the old one, but too many flags to have a definitive one. |
I think the current functionality are great, just the issue that you have to unselect before selecting again if the new selected object are above. |
Try this: https://jsfiddle.net/ecvctazk/33/ Now, it's ok for me (like 1.6.2) |
This works as expected : ) |
With the new build : https://jsfiddle.net/ecvctazk/49/ |
It's really annoying bug and our team needs a fix for it. |
i m not adding another flag. feel free to take that code and port in the library. As soon as i have some time i will search for a solution that may work good with both preserve object stacking tru and false. |
Can you put up a fiddle for this? |
you mean with new code? |
Yeah, so i can test it out : ) |
I think i ll not do it but just because with all the little time i have and the effort i m putting, the time spent in making a fiddle is better spent in fixing a bug or cleaning up a feature. |
Version
1.6.3
Test Case
http://jsfiddle.net/ecvctazk/
Steps to reproduce
Try to select the inner object
Expected Behavior
You should be able to select the inner object
Actual Behavior
You always got the background object selected
The text was updated successfully, but these errors were encountered: