diff --git a/__tests__/snapshot/core/examples/features/image.html.jpg b/__tests__/snapshot/core/examples/features/image.html.jpg deleted file mode 100644 index 0b71d94..0000000 Binary files a/__tests__/snapshot/core/examples/features/image.html.jpg and /dev/null differ diff --git a/__tests__/snapshot/core/examples/features/rect.html.jpg b/__tests__/snapshot/core/examples/features/rect.html.jpg deleted file mode 100644 index f927f89..0000000 Binary files a/__tests__/snapshot/core/examples/features/rect.html.jpg and /dev/null differ diff --git a/__tests__/snapshot/core/examples/features/svg.html.jpg b/__tests__/snapshot/core/examples/features/svg.html.jpg deleted file mode 100644 index e270a15..0000000 Binary files a/__tests__/snapshot/core/examples/features/svg.html.jpg and /dev/null differ diff --git a/__tests__/snapshot/core/examples/features/text.html.jpg b/__tests__/snapshot/core/examples/features/text.html.jpg deleted file mode 100644 index 19e4adc..0000000 Binary files a/__tests__/snapshot/core/examples/features/text.html.jpg and /dev/null differ diff --git a/__tests__/snapshot/core/examples/test/image.html.jpg b/__tests__/snapshot/core/examples/test/image.html.jpg new file mode 100644 index 0000000..d035ae8 Binary files /dev/null and b/__tests__/snapshot/core/examples/test/image.html.jpg differ diff --git a/__tests__/snapshot/core/examples/test/rect.html.jpg b/__tests__/snapshot/core/examples/test/rect.html.jpg new file mode 100644 index 0000000..71da3f8 Binary files /dev/null and b/__tests__/snapshot/core/examples/test/rect.html.jpg differ diff --git a/__tests__/snapshot/core/examples/test/svg.html.jpg b/__tests__/snapshot/core/examples/test/svg.html.jpg new file mode 100644 index 0000000..27e783d Binary files /dev/null and b/__tests__/snapshot/core/examples/test/svg.html.jpg differ diff --git a/__tests__/snapshot/core/examples/test/text.html.jpg b/__tests__/snapshot/core/examples/test/text.html.jpg new file mode 100644 index 0000000..9a3cb4e Binary files /dev/null and b/__tests__/snapshot/core/examples/test/text.html.jpg differ diff --git a/packages/board/src/lib/scroller.ts b/packages/board/src/lib/scroller.ts index 10950dc..7980d8b 100644 --- a/packages/board/src/lib/scroller.ts +++ b/packages/board/src/lib/scroller.ts @@ -2,6 +2,7 @@ import { TypePoint, TypeScreenPosition } from '@idraw/types'; +import util from '@idraw/util'; type TypeOptions = { width: number, @@ -172,10 +173,16 @@ export class Scroller { private _getOpts(opts: TypeOptions): TypePrivateOptions { const options = { ...{ scrollConfig: defaultScrollConfig }, ...opts}; if (!options.scrollConfig) { - options.scrollConfig = {...{}, ...defaultScrollConfig} + options.scrollConfig = defaultScrollConfig; + } + if (!(options.scrollConfig.lineWidth > 0)) { + options.scrollConfig.lineWidth = defaultScrollConfig.lineWidth; } - options.scrollConfig.lineWidth = Math.max(options.scrollConfig.lineWidth, defaultScrollConfig.lineWidth); + + if (util.color.isColorStr(options.scrollConfig.color) !== true) { + options.scrollConfig.color = options.scrollConfig.color; + } return options; } } diff --git a/packages/core/examples/features/image.html b/packages/core/examples/features/image.html deleted file mode 100644 index 2490f0e..0000000 --- a/packages/core/examples/features/image.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - -
-
-
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/packages/core/examples/features/rect.html b/packages/core/examples/features/rect.html deleted file mode 100644 index 2490f0e..0000000 --- a/packages/core/examples/features/rect.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - -
-
-
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/packages/core/examples/features/svg.html b/packages/core/examples/features/svg.html deleted file mode 100644 index 2490f0e..0000000 --- a/packages/core/examples/features/svg.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - -
-
-
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/packages/core/examples/features/text.html b/packages/core/examples/features/text.html deleted file mode 100644 index 2490f0e..0000000 --- a/packages/core/examples/features/text.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - -
-
-
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/packages/core/examples/test/image.html b/packages/core/examples/test/image.html new file mode 100644 index 0000000..c4a64a3 --- /dev/null +++ b/packages/core/examples/test/image.html @@ -0,0 +1,40 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/packages/core/examples/test/rect.html b/packages/core/examples/test/rect.html new file mode 100644 index 0000000..070e865 --- /dev/null +++ b/packages/core/examples/test/rect.html @@ -0,0 +1,40 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/packages/core/examples/test/svg.html b/packages/core/examples/test/svg.html new file mode 100644 index 0000000..070e865 --- /dev/null +++ b/packages/core/examples/test/svg.html @@ -0,0 +1,40 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/packages/core/examples/test/text.html b/packages/core/examples/test/text.html new file mode 100644 index 0000000..a9be1a9 --- /dev/null +++ b/packages/core/examples/test/text.html @@ -0,0 +1,40 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 3712c12..d375709 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -66,7 +66,15 @@ class Core { this[_data] = { elements: [] }; this[_opts] = opts; this[_config] = mergeConfig(config || {}); - this[_board] = new Board(mount, this[_opts]); + + this[_board] = new Board(mount, { + ...this[_opts], + canScroll: config?.scrollWrapper?.use, + scrollConfig: { + color: config?.scrollWrapper?.color || '#a0a0a0', + lineWidth: config?.scrollWrapper?.lineWidth || 12, + } + }); this[_renderer] = new Renderer(this[_board]); this[_element] = new Element(this[_board].getContext()); this[_helper] = new Helper(this[_board], this[_config]); diff --git a/packages/types/src/lib/config.ts b/packages/types/src/lib/config.ts index 8878d71..10bfbf1 100644 --- a/packages/types/src/lib/config.ts +++ b/packages/types/src/lib/config.ts @@ -4,6 +4,11 @@ type TypeConfig = { dotSize?: number, lineWidth?: number, lineDash?: number[], + }, + scrollWrapper?: { + use?: boolean, + color?: string, + lineWidth?: number, } } @@ -13,7 +18,7 @@ type TypeConfigStrict = TypeConfig & { dotSize: number, lineWidth: number, lineDash: number[], - } + }, } export { diff --git a/scripts/screen.config.js b/scripts/screen.config.js index 6f55316..e953b27 100644 --- a/scripts/screen.config.js +++ b/scripts/screen.config.js @@ -8,10 +8,10 @@ const pageList = [ { path: 'board/examples/test/scale-004.html', w: 600, h: 400, delay: 500 }, { path: 'board/examples/test/scale-005.html', w: 600, h: 400, delay: 500 }, { path: 'board/examples/test/scroll.html', w: 700, h: 500, delay: 500 }, - { path: 'core/examples/features/rect.html', w: 600, h: 400, delay: 500 }, - { path: 'core/examples/features/text.html', w: 600, h: 400, delay: 500 }, - { path: 'core/examples/features/svg.html', w: 600, h: 400, delay: 500 }, - { path: 'core/examples/features/image.html', w: 600, h: 400, delay: 500 }, + { path: 'core/examples/test/rect.html', w: 600, h: 400, delay: 500 }, + { path: 'core/examples/test/text.html', w: 600, h: 400, delay: 500 }, + { path: 'core/examples/test/svg.html', w: 600, h: 400, delay: 500 }, + { path: 'core/examples/test/image.html', w: 600, h: 400, delay: 500 }, { 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 },