Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
Add minimum resize height/width
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed Jul 13, 2018
1 parent 836517a commit 0ea0749
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/ui/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ 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;
var startHeight;

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);
Expand Down

0 comments on commit 0ea0749

Please sign in to comment.