mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
Add minimum resize height/width
This commit is contained in:
+6
-2
@@ -47,6 +47,8 @@ import { uiCmd } from './cmd';
|
||||
function buildResizeListener(target, eventName, dispatch, options) {
|
||||
var resizeOnX = !!options.resizeOnX;
|
||||
var resizeOnY = !!options.resizeOnY;
|
||||
var minHeight = options.minHeight || 240;
|
||||
var minWidth = options.minWidth || 320;
|
||||
var startX;
|
||||
var startY;
|
||||
var startWidth;
|
||||
@@ -54,11 +56,13 @@ function buildResizeListener(target, eventName, dispatch, options) {
|
||||
|
||||
function startResize() {
|
||||
if (resizeOnX) {
|
||||
target.style('width', (startWidth + d3_event.clientX - startX) + 'px');
|
||||
var newWidth = Math.max(minWidth, startWidth + d3_event.clientX - startX);
|
||||
target.style('width', newWidth + 'px');
|
||||
}
|
||||
|
||||
if (resizeOnY) {
|
||||
target.style('height', (startHeight + startY - d3_event.clientY) + 'px');
|
||||
var newHeight = Math.max(minHeight, startHeight + startY - d3_event.clientY);
|
||||
target.style('height', newHeight + 'px');
|
||||
}
|
||||
|
||||
dispatch.call(eventName, target);
|
||||
|
||||
Reference in New Issue
Block a user