mirror of
https://github.com/slidevjs/rough-notation.git
synced 2026-01-14 17:44:21 +01:00
feat!: directly pass through rough js options
This commit is contained in:
@@ -83,7 +83,7 @@ export function renderAnnotation(
|
||||
const animate = (config.animate === undefined) ? true : (!!config.animate)
|
||||
const iterations = config.iterations || 2
|
||||
const rtl = config.rtl ? 1 : 0
|
||||
const o = getOptions('single', seed, config.overrides)
|
||||
const o = getOptions('single', seed, config)
|
||||
|
||||
switch (config.type) {
|
||||
case 'underline': {
|
||||
@@ -183,7 +183,7 @@ export function renderAnnotation(
|
||||
break
|
||||
}
|
||||
case 'circle': {
|
||||
const doubleO = getOptions('double', seed, config.overrides)
|
||||
const doubleO = getOptions('double', seed, config)
|
||||
const width = rect.w + (padding[1] + padding[3])
|
||||
const height = rect.h + (padding[0] + padding[2])
|
||||
const x = rect.x - padding[3] + (width / 2)
|
||||
@@ -199,7 +199,7 @@ export function renderAnnotation(
|
||||
break
|
||||
}
|
||||
case 'highlight': {
|
||||
const o = getOptions('highlight', seed, config.overrides)
|
||||
const o = getOptions('highlight', seed, config)
|
||||
strokeWidth = rect.h * 0.95
|
||||
const y = rect.y + (rect.h / 2)
|
||||
for (let i = rtl; i < iterations + rtl; i++) {
|
||||
|
||||
@@ -23,6 +23,17 @@ class RoughAnnotationImpl implements RoughAnnotation {
|
||||
this.attach()
|
||||
}
|
||||
|
||||
getConfig<T extends keyof RoughAnnotationConfig>(key: T) {
|
||||
return this._config[key]
|
||||
}
|
||||
|
||||
setConfig<T extends keyof RoughAnnotationConfig>(key: T, value: RoughAnnotationConfig[T]) {
|
||||
if (this._config[key] !== value) {
|
||||
this._config[key] = value
|
||||
this.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
get animate() { return this._config.animate }
|
||||
set animate(value) { this._config.animate = value }
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface RoughAnnotationConfig extends RoughAnnotationConfigBase {
|
||||
rtl?: boolean
|
||||
}
|
||||
|
||||
export interface RoughAnnotationConfigBase {
|
||||
export interface RoughAnnotationConfigBase extends Partial<ResolvedOptions> {
|
||||
animate?: boolean // defaults to true
|
||||
animationDuration?: number // defaults to 1000ms
|
||||
color?: string // defaults to currentColor
|
||||
@@ -30,10 +30,6 @@ export interface RoughAnnotationConfigBase {
|
||||
* Additional class to add to the root SVG element
|
||||
*/
|
||||
class?: string
|
||||
/**
|
||||
* RoughJS options
|
||||
*/
|
||||
overrides?: Partial<ResolvedOptions>
|
||||
}
|
||||
|
||||
export interface RoughAnnotation extends RoughAnnotationConfigBase {
|
||||
|
||||
Reference in New Issue
Block a user