@idraw/board
Advanced tools
Comparing version 0.0.4-alpha.10 to 0.0.4-alpha.11
@@ -92,3 +92,3 @@ 'use strict'; | ||
function isColorStr(color) { | ||
return typeof color === 'string' && /^\#[0-9a-z]{3,8}$/i.test(color); | ||
return typeof color === 'string' && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color); | ||
} | ||
@@ -444,2 +444,5 @@ | ||
} | ||
Context.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Context.prototype.calcDeviceNum = function (num) { | ||
@@ -639,2 +642,5 @@ return num * this._opts.devicePixelRatio; | ||
}; | ||
Scroller.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Scroller.prototype.isPointAtScrollY = function (p) { | ||
@@ -739,4 +745,2 @@ var _a = this._opts, width = _a.width, height = _a.height, scrollConfig = _a.scrollConfig; | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var _canvas = Symbol('_canvas'); | ||
@@ -760,2 +764,6 @@ var _displayCanvas = Symbol('_displayCanvas'); | ||
var _doMoveScroll = Symbol('_doMoveScroll'); | ||
var _resetContext = Symbol('_resetContext'); | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var Board = /** @class */ (function () { | ||
@@ -854,2 +862,13 @@ function Board(mount, opts) { | ||
}; | ||
Board.prototype.resetSize = function (opts) { | ||
this[_opts] = __assign(__assign({}, this[_opts]), opts); | ||
this[_resetContext](); | ||
this[_ctx].resetSize(opts); | ||
this[_scroller].resetSize({ | ||
width: this[_opts].width, | ||
height: this[_opts].height, | ||
devicePixelRatio: this[_opts].devicePixelRatio | ||
}); | ||
this.draw(); | ||
}; | ||
Board.prototype[(_a = _hasRendered, _render)] = function () { | ||
@@ -859,2 +878,7 @@ if (this[_hasRendered] === true) { | ||
} | ||
this[_resetContext](); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
Board.prototype[_resetContext] = function () { | ||
var _b = this[_opts], width = _b.width, height = _b.height, contextWidth = _b.contextWidth, contextHeight = _b.contextHeight, devicePixelRatio = _b.devicePixelRatio; | ||
@@ -869,4 +893,2 @@ this[_canvas].width = contextWidth * devicePixelRatio; | ||
}); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
@@ -873,0 +895,0 @@ Board.prototype[_parsePrivateOptions] = function (opts) { |
@@ -0,1 +1,3 @@ | ||
import { TypeBoardOptions } from '@idraw/types'; | ||
import { TypeBoardSizeOptions } from '@idraw/types'; | ||
import { TypeContext } from '@idraw/types'; | ||
@@ -18,3 +20,3 @@ import { TypePoint } from '@idraw/types'; | ||
private [_scroller]; | ||
constructor(mount: HTMLDivElement, opts: Options); | ||
constructor(mount: HTMLDivElement, opts: TypeBoardOptions); | ||
getDisplayContext(): CanvasRenderingContext2D; | ||
@@ -47,3 +49,5 @@ getOriginContext(): CanvasRenderingContext2D; | ||
resetCursor(): void; | ||
resetSize(opts: TypeBoardSizeOptions): void; | ||
private [_render]; | ||
private [_resetContext]; | ||
private [_parsePrivateOptions]; | ||
@@ -69,3 +73,4 @@ private [_calcScreen]; | ||
private _transform; | ||
constructor(ctx: CanvasRenderingContext2D, opts: Options_2); | ||
constructor(ctx: CanvasRenderingContext2D, opts: Options); | ||
resetSize(opts: TypeBoardSizeOptions): void; | ||
calcDeviceNum(num: number): number; | ||
@@ -143,12 +148,2 @@ calcScreenNum(num: number): number; | ||
contextHeight: number; | ||
devicePixelRatio?: number; | ||
canScroll?: boolean; | ||
scrollConfig?: TypeScrollConfig; | ||
}; | ||
declare type Options_2 = { | ||
width: number; | ||
height: number; | ||
contextWidth: number; | ||
contextHeight: number; | ||
devicePixelRatio: number; | ||
@@ -165,2 +160,4 @@ }; | ||
declare const _resetContext: unique symbol; | ||
declare const _scroller: unique symbol; | ||
@@ -186,9 +183,4 @@ | ||
declare type TypeScrollConfig = { | ||
color: string; | ||
lineWidth: number; | ||
}; | ||
declare const _watcher: unique symbol; | ||
export { } |
@@ -90,3 +90,3 @@ /*! ***************************************************************************** | ||
function isColorStr(color) { | ||
return typeof color === 'string' && /^\#[0-9a-z]{3,8}$/i.test(color); | ||
return typeof color === 'string' && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color); | ||
} | ||
@@ -442,2 +442,5 @@ | ||
} | ||
Context.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Context.prototype.calcDeviceNum = function (num) { | ||
@@ -637,2 +640,5 @@ return num * this._opts.devicePixelRatio; | ||
}; | ||
Scroller.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Scroller.prototype.isPointAtScrollY = function (p) { | ||
@@ -737,4 +743,2 @@ var _a = this._opts, width = _a.width, height = _a.height, scrollConfig = _a.scrollConfig; | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var _canvas = Symbol('_canvas'); | ||
@@ -758,2 +762,6 @@ var _displayCanvas = Symbol('_displayCanvas'); | ||
var _doMoveScroll = Symbol('_doMoveScroll'); | ||
var _resetContext = Symbol('_resetContext'); | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var Board = /** @class */ (function () { | ||
@@ -852,2 +860,13 @@ function Board(mount, opts) { | ||
}; | ||
Board.prototype.resetSize = function (opts) { | ||
this[_opts] = __assign(__assign({}, this[_opts]), opts); | ||
this[_resetContext](); | ||
this[_ctx].resetSize(opts); | ||
this[_scroller].resetSize({ | ||
width: this[_opts].width, | ||
height: this[_opts].height, | ||
devicePixelRatio: this[_opts].devicePixelRatio | ||
}); | ||
this.draw(); | ||
}; | ||
Board.prototype[(_a = _hasRendered, _render)] = function () { | ||
@@ -857,2 +876,7 @@ if (this[_hasRendered] === true) { | ||
} | ||
this[_resetContext](); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
Board.prototype[_resetContext] = function () { | ||
var _b = this[_opts], width = _b.width, height = _b.height, contextWidth = _b.contextWidth, contextHeight = _b.contextHeight, devicePixelRatio = _b.devicePixelRatio; | ||
@@ -867,4 +891,2 @@ this[_canvas].width = contextWidth * devicePixelRatio; | ||
}); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
@@ -871,0 +893,0 @@ Board.prototype[_parsePrivateOptions] = function (opts) { |
@@ -94,3 +94,3 @@ this.iDraw = this.iDraw || {}; | ||
function isColorStr(color) { | ||
return typeof color === 'string' && /^\#[0-9a-z]{3,8}$/i.test(color); | ||
return typeof color === 'string' && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color); | ||
} | ||
@@ -446,2 +446,5 @@ | ||
} | ||
Context.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Context.prototype.calcDeviceNum = function (num) { | ||
@@ -641,2 +644,5 @@ return num * this._opts.devicePixelRatio; | ||
}; | ||
Scroller.prototype.resetSize = function (opts) { | ||
this._opts = __assign(__assign({}, this._opts), opts); | ||
}; | ||
Scroller.prototype.isPointAtScrollY = function (p) { | ||
@@ -741,4 +747,2 @@ var _a = this._opts, width = _a.width, height = _a.height, scrollConfig = _a.scrollConfig; | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var _canvas = Symbol('_canvas'); | ||
@@ -762,2 +766,6 @@ var _displayCanvas = Symbol('_displayCanvas'); | ||
var _doMoveScroll = Symbol('_doMoveScroll'); | ||
var _resetContext = Symbol('_resetContext'); | ||
var _a; | ||
var throttle = index.time.throttle; | ||
var Board = /** @class */ (function () { | ||
@@ -856,2 +864,13 @@ function Board(mount, opts) { | ||
}; | ||
Board.prototype.resetSize = function (opts) { | ||
this[_opts] = __assign(__assign({}, this[_opts]), opts); | ||
this[_resetContext](); | ||
this[_ctx].resetSize(opts); | ||
this[_scroller].resetSize({ | ||
width: this[_opts].width, | ||
height: this[_opts].height, | ||
devicePixelRatio: this[_opts].devicePixelRatio | ||
}); | ||
this.draw(); | ||
}; | ||
Board.prototype[(_a = _hasRendered, _render)] = function () { | ||
@@ -861,2 +880,7 @@ if (this[_hasRendered] === true) { | ||
} | ||
this[_resetContext](); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
Board.prototype[_resetContext] = function () { | ||
var _b = this[_opts], width = _b.width, height = _b.height, contextWidth = _b.contextWidth, contextHeight = _b.contextHeight, devicePixelRatio = _b.devicePixelRatio; | ||
@@ -871,4 +895,2 @@ this[_canvas].width = contextWidth * devicePixelRatio; | ||
}); | ||
this[_initEvent](); | ||
this[_hasRendered] = true; | ||
}; | ||
@@ -875,0 +897,0 @@ Board.prototype[_parsePrivateOptions] = function (opts) { |
{ | ||
"name": "@idraw/board", | ||
"version": "0.0.4-alpha.10", | ||
"version": "0.0.4-alpha.11", | ||
"description": "", | ||
@@ -26,6 +26,6 @@ "main": "dist/index.cjs.js", | ||
"devDependencies": { | ||
"@idraw/types": "^0.0.4-alpha.10" | ||
"@idraw/types": "^0.0.4-alpha.11" | ||
}, | ||
"dependencies": { | ||
"@idraw/util": "^0.0.4-alpha.10" | ||
"@idraw/util": "^0.0.4-alpha.11" | ||
}, | ||
@@ -35,3 +35,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "1ad4b66ffe407adfa5a449898c4fa82250663d6b" | ||
"gitHead": "2ed2fbc354f7dd763471682cf66142d3ea260da5" | ||
} |
129350
3222
Updated@idraw/util@^0.0.4-alpha.11