diff --git a/.eslintrc.js b/.eslintrc.js index 908eb7e..f555e9d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,5 +24,5 @@ module.exports = { "@typescript-eslint/rule-name": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/explicit-module-boundary-types": "off" - } -} \ No newline at end of file + }, +}; diff --git a/.gitignore b/.gitignore index 2378928..9aaa624 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,7 @@ temp/ /temp/ __tests__/diff +__tests__/test-result # __tests__/snapshot reports/ diff --git a/__tests__/e2e.test.js b/__tests__/e2e.test.js index cd33e39..a0ef183 100644 --- a/__tests__/e2e.test.js +++ b/__tests__/e2e.test.js @@ -10,6 +10,7 @@ const { createScreenshot } = require('../scripts/util/screen'); const snapshotDir = path.join(__dirname, 'snapshot'); const diffDir = path.join(__dirname, 'diff'); +const testResultDir = path.join(__dirname, 'test-result'); const { PNG } = pngjs; async function diff() { @@ -34,6 +35,7 @@ async function diff() { const failedPixel = pixelmatch(expected.data, actual.data, diffBuf.data, actual.width, actual.height); const failRate = failedPixel / (width * height); if (failRate > 0) { + (await jimp.read(actual)).scale(1).quality(100).write(parsePicPath(path.join(testResultDir, p.path))); (await jimp.read(diffBuf)).scale(1).quality(100).write(parsePicPath(path.join(diffDir, p.path))); } diffRateList.push({ diff --git a/docs/todo/core.md b/docs/todo/core.md index d3d24bc..b859d39 100644 --- a/docs/todo/core.md +++ b/docs/todo/core.md @@ -1,5 +1,6 @@ # @idraw/core +* [] Options default data * [] Support gradient color * [] Listen keyboard action * [] Keep all num two decimals diff --git a/packages/core/examples/test/scroll.html b/packages/core/examples/test/scroll.html index e117b98..18a636a 100644 --- a/packages/core/examples/test/scroll.html +++ b/packages/core/examples/test/scroll.html @@ -33,7 +33,11 @@ contextWidth: 1000, contextHeight: 900, devicePixelRatio: 4, - canScroll: true + }, { + scrollWrapper: { + use: true, + lineWidth: 20, + } }); core.initData(data); const result = core.scale(1); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 32600e3..b174977 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -82,7 +82,7 @@ class Core { this[_helper].updateConfig(this[_data], { width: this[_opts].width, height: this[_opts].height, - canScroll: this[_opts].canScroll === true, + canScroll: this[_config]?.scrollWrapper?.use === true, selectedUUID: this[_selectedUUID], selectedUUIDList: this[_selectedUUIDList], devicePixelRatio: this[_opts].devicePixelRatio, diff --git a/packages/idraw/src/index.ts b/packages/idraw/src/index.ts index 7e3fbed..7911c37 100644 --- a/packages/idraw/src/index.ts +++ b/packages/idraw/src/index.ts @@ -37,7 +37,8 @@ class IDraw extends Core { height: opts.height, contextWidth: opts.contextWidth, contextHeight: opts.contextHeight, - devicePixelRatio: opts.devicePixelRatio + devicePixelRatio: opts.devicePixelRatio, + onlyRender: opts.onlyRender }, config || {}); this[_opts] = this._createOpts(opts); this[_initEvent](); diff --git a/packages/types/src/lib/core.ts b/packages/types/src/lib/core.ts index b05a7d6..857395f 100644 --- a/packages/types/src/lib/core.ts +++ b/packages/types/src/lib/core.ts @@ -5,7 +5,6 @@ type TypeCoreOptions = { devicePixelRatio: number; contextWidth: number; contextHeight: number; - canScroll?: boolean; onlyRender?: boolean; }