-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
regions plugin: fix region ignoring minLength when being resized #2002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! can you also add a changelog entry?
src/plugin/regions/region.js
Outdated
this.update({ | ||
start: Math.min(this.start + delta, this.end), | ||
end: Math.max(this.start + delta, this.end) | ||
}); | ||
} else { | ||
// Check if changing the end by the given delta would result in the region being smaller than minLength | ||
// Ignore cases where we are making the region wider rather than shrinking it | ||
if (delta < 0 && Math.abs((this.end + delta) - this.start) < this.minLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question about Math.abs
. Also curious why we have to check for delta > 0
and delta < 0
; the checks are sorta fine, but was there a specific reason to put them in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since minLength isn't checked everywhere, it's actually possible to manually call this.update() and set the region to a size smaller than minLength. The delta check makes sure that if the area is too small, you can still make it bigger, but not shrink it further when dragging it with the mouse. A better fix would be to make sure the region can never be smaller than minLength, but I'm not familiar enough with this plugin to make that change.
Hi great idea and very useful! It would be even better if the |
Hi, @sundayz, are you planning to open a PR for this, or can I proceed? |
@marizuccara You can do it if you'd like :) I will try to fix #2006 soon, should we do 1 PR to fix multiple issues with regions, or do a separate PR for each issue? #1925 also added something to regions in 4.0 which should be changed to a configuration option since it stops the seeker from working within regions |
One per issue, it makes it easier to track changes later on. I was thinking of doing a 4.1.0 release next week, but it can wait till regions plugin improvements you talk about are merged. |
…spaugh#2002) * fix region not respecting minLength when being resized * fix region handle CSS in example being hard to grab when the region is small * Change region handle default width to 2px rather than 1% of the region width * Remove redundant math.abs check * add changelog entry (katspaugh#2002)
Short description of changes:
Breaking in the external API:
None
Breaking changes in the internal API:
None
Todos/Notes:
The resizing behaviour in general could do with some improvements. For example I don't think you should be able to drag regions to size 0, because then you can't grab them again and you lose them. Maybe regions could have a default minLength: 0.1 or so.
Other possible future enhancements:
Related Issues and other PRs:
fixes #2001
closes #2008