mirror of
https://github.com/slidevjs/rough-notation.git
synced 2026-01-19 20:01:33 +01:00
feat: .show() returns promise
This commit is contained in:
@@ -68,7 +68,14 @@ function parsePadding(config: RoughAnnotationConfig): FullPadding {
|
||||
return [5, 5, 5, 5]
|
||||
}
|
||||
|
||||
export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAnnotationConfig, animationGroupDelay: number, animationDuration: number, seed: number) {
|
||||
export function renderAnnotation(
|
||||
svg: SVGSVGElement,
|
||||
rect: Rect,
|
||||
config: RoughAnnotationConfig,
|
||||
animationGroupDelay: number,
|
||||
animationDuration: number,
|
||||
seed: number,
|
||||
): Promise<void> {
|
||||
const opList: OpSet[] = []
|
||||
let strokeWidth = config.strokeWidth || 2
|
||||
const padding = parsePadding(config)
|
||||
@@ -239,8 +246,14 @@ export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAn
|
||||
style.animation = `rough-notation-dash ${duration}ms ease-out ${delay}ms forwards`
|
||||
durationOffset += duration
|
||||
}
|
||||
return sleep(animationDuration + animationGroupDelay)
|
||||
}
|
||||
}
|
||||
return sleep(0)
|
||||
}
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise<void>(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
function opsToPath(opList: OpSet[]): string[] {
|
||||
@@ -253,7 +266,6 @@ function opsToPath(opList: OpSet[]): string[] {
|
||||
case 'move':
|
||||
if (path.trim())
|
||||
paths.push(path.trim())
|
||||
|
||||
path = `M${data[0]} ${data[1]} `
|
||||
break
|
||||
case 'bcurveTo':
|
||||
|
||||
Reference in New Issue
Block a user