Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3da79a

Browse files
committed
Corner drag code
1 parent db79866 commit f3da79a

9 files changed

+148
-59
lines changed

dist/dd-resizable.js

Lines changed: 47 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dd-resizable.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/dd-resizable.js

Lines changed: 47 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/dd-resizable.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/gridstack-all.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es5/gridstack-all.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack-all.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack-all.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dd-resizable.ts

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,26 +251,57 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
251251

252252
if (typeof fixedAspectRatio !== 'undefined' && fixedAspectRatio != 0 && !isNaN(fixedAspectRatio) && isFinite(fixedAspectRatio))
253253
{
254-
if (dir.indexOf('e') > -1) {
255-
newRect.width += offsetX;
256-
newRect.height += Math.round(offsetX / fixedAspectRatio);
257-
} else if (dir.indexOf('w') > -1) {
258-
newRect.width -= offsetX;
259-
newRect.left += offsetX;
254+
// If the window is being resized using the corner
255+
if (dir.length > 1) {
256+
257+
if (offsetX > offsetY) {
258+
if (dir.indexOf('e') > -1) {
259+
newRect.width += offsetX;
260+
newRect.height += Math.round(offsetX / fixedAspectRatio);
261+
} else if (dir.indexOf('w') > -1) {
262+
newRect.width -= offsetX;
263+
newRect.left += offsetX;
264+
265+
newRect.height -= Math.round(offsetX / fixedAspectRatio);
266+
newRect.top += Math.round(offsetX / fixedAspectRatio);
267+
}
268+
} else {
269+
if (dir.indexOf('s') > -1) {
270+
newRect.height += offsetY;
271+
newRect.width += Math.round(offsetY * fixedAspectRatio);
272+
} else if (dir.indexOf('n') > -1) {
273+
newRect.height -= offsetY;
274+
newRect.top += offsetY;
275+
276+
newRect.width -= Math.round(offsetY * fixedAspectRatio);
277+
newRect.left += Math.round(offsetY * fixedAspectRatio);
278+
}
279+
}
280+
260281

261-
newRect.height -= Math.round(offsetX / fixedAspectRatio);
262-
newRect.top += Math.round(offsetX / fixedAspectRatio);
263-
}
264282

265-
if (dir.indexOf('s') > -1) {
266-
newRect.height += offsetY;
267-
newRect.width += Math.round(offsetY * fixedAspectRatio);
268-
} else if (dir.indexOf('n') > -1) {
269-
newRect.height -= offsetY;
270-
newRect.top += offsetY;
283+
} else {
284+
if (dir.indexOf('e') > -1) {
285+
newRect.width += offsetX;
286+
newRect.height += Math.round(offsetX / fixedAspectRatio);
287+
} else if (dir.indexOf('w') > -1) {
288+
newRect.width -= offsetX;
289+
newRect.left += offsetX;
290+
291+
newRect.height -= Math.round(offsetX / fixedAspectRatio);
292+
newRect.top += Math.round(offsetX / fixedAspectRatio);
293+
}
271294

272-
newRect.width -= Math.round(offsetY * fixedAspectRatio);
273-
newRect.left += Math.round(offsetY * fixedAspectRatio);
295+
if (dir.indexOf('s') > -1) {
296+
newRect.height += offsetY;
297+
newRect.width += Math.round(offsetY * fixedAspectRatio);
298+
} else if (dir.indexOf('n') > -1) {
299+
newRect.height -= offsetY;
300+
newRect.top += offsetY;
301+
302+
newRect.width -= Math.round(offsetY * fixedAspectRatio);
303+
newRect.left += Math.round(offsetY * fixedAspectRatio);
304+
}
274305
}
275306
}
276307
else

0 commit comments

Comments
 (0)