diff --git a/__tests__/snapshot/core/examples/test/reset-size.html.jpg b/__tests__/snapshot/core/examples/test/reset-size.html.jpg new file mode 100644 index 0000000..f29302d Binary files /dev/null and b/__tests__/snapshot/core/examples/test/reset-size.html.jpg differ diff --git a/docs/todo/board.md b/docs/todo/board.md index 919e8f8..885c267 100644 --- a/docs/todo/board.md +++ b/docs/todo/board.md @@ -1,3 +1,3 @@ # @idraw/board -* [] Reset board's size \ No newline at end of file +* [x] Reset board's size \ No newline at end of file diff --git a/packages/core/examples/test/reset-size.html b/packages/core/examples/test/reset-size.html new file mode 100644 index 0000000..b6f5323 --- /dev/null +++ b/packages/core/examples/test/reset-size.html @@ -0,0 +1,72 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index d375709..49a8d9e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,13 +1,9 @@ import { - TypeData, - TypePoint, + TypeData, TypePoint, TypeBoardSizeOptions, TypeHelperWrapperDotDirection, - TypeConfig, - TypeConfigStrict, - TypeElement, - TypeElemDesc, - TypeCoreOptions, - TypeScreenContext, + TypeConfig, TypeConfigStrict, + TypeElement, TypeElemDesc, + TypeCoreOptions, TypeScreenContext, } from '@idraw/types'; import Board from '@idraw/board'; import util from '@idraw/util'; @@ -97,6 +93,12 @@ class Core { this[_renderer].render(this[_data], this[_helper].getConfig()); } + resetSize(opts: TypeBoardSizeOptions) { + this[_opts] = { ...this[_opts], ...opts }; + this[_board].resetSize(opts); + this.draw(); + } + selectElement(index: number, opts?: { useMode?: boolean }): void { if (this[_data].elements[index]) { const uuid = this[_data].elements[index].uuid; diff --git a/packages/types/src/lib/core.ts b/packages/types/src/lib/core.ts index 1ff3046..de4dbf3 100644 --- a/packages/types/src/lib/core.ts +++ b/packages/types/src/lib/core.ts @@ -1,3 +1,4 @@ + type TypeCoreOptions = { width: number; height: number; diff --git a/scripts/screen.config.js b/scripts/screen.config.js index 2059c95..dafafe0 100644 --- a/scripts/screen.config.js +++ b/scripts/screen.config.js @@ -16,6 +16,8 @@ const pageList = [ { path: 'core/examples/test/scale-001.html', w: 600, h: 400, delay: 500 }, { path: 'core/examples/test/scale-002.html', w: 600, h: 400, delay: 500 }, { path: 'core/examples/test/scale-003.html', w: 600, h: 400, delay: 500 }, + { path: 'core/examples/test/reset-size.html', w: 300, h: 300, delay: 500 }, + // { path: 'core/examples/test.html', w: 600, h: 600, delay: 8000 }, ]