-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alexandr Todorov <Alexandr.Todorov@technosoft.nl>
- Loading branch information
1 parent
f7a904a
commit 84dacc7
Showing
5 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export enum ResizeHandles { | ||
n = 'n', | ||
ne = 'ne', | ||
e = 'e', | ||
se = 'se', | ||
s = 's', | ||
sw = 'sw', | ||
w = 'w', | ||
nw = 'nw' | ||
} | ||
|
||
export type ResizeHandleType = ResizeHandles.n | ResizeHandles.ne | ResizeHandles.e | ResizeHandles.se | | ||
ResizeHandles.s | ResizeHandles.sw | ResizeHandles.w | ResizeHandles.nw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ResizeHandles, ResizeHandleType } from './models'; | ||
|
||
function onlyUnique(value: any, index: number, self: any) { | ||
return self.indexOf(value) === index; | ||
} | ||
|
||
export function getResizeHandleTypesOnly(handles: string | undefined): ResizeHandleType[] { | ||
const handlesArray: ResizeHandleType[] = []; | ||
|
||
if (handles) { | ||
let allEntries = handles.replace(/\s/g, '').split(','); | ||
|
||
// remove duplicates | ||
allEntries = allEntries.filter(onlyUnique); | ||
|
||
// add only ResizeHandleType items | ||
allEntries.forEach((child) => { | ||
if (child in ResizeHandles) { | ||
handlesArray.push(child as ResizeHandleType); | ||
} | ||
}); | ||
} | ||
|
||
return handlesArray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export class App { | ||
items = [ | ||
{ x: 0, y: 0, w: 2, h: 1 }, | ||
{ x: 1, y: 1, w: 2, h: 2 }, | ||
{ x: 3, y: 2, w: 1, h: 2 } | ||
{ x: 0, y: 0, w: 2, h: 1, id: 11, resizeHandles: 'e' }, | ||
{ x: 1, y: 1, w: 2, h: 2, id: 22 }, | ||
{ x: 3, y: 2, w: 1, h: 2, id: 33 } | ||
]; | ||
} |