mirror of
https://github.com/slidevjs/rough-notation.git
synced 2026-01-14 17:44:21 +01:00
fixed a bug in rehighlighting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rough-notation",
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.3",
|
||||
"description": "Create and animate hand-drawn annotations on a web page",
|
||||
"main": "lib/rough-notation.cjs.js",
|
||||
"module": "lib/rough-notation.esm.js",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Rect, RoughAnnotationConfig, SVG_NS, DEFAULT_ANIMATION_DURATION, FullPadding } from './model.js';
|
||||
import { Rect, RoughAnnotationConfig, SVG_NS, FullPadding } from './model.js';
|
||||
import { ResolvedOptions, OpSet } from 'roughjs/bin/core';
|
||||
import { line, rectangle, ellipse } from 'roughjs/bin/renderer';
|
||||
|
||||
@@ -54,7 +54,7 @@ function parsePadding(config: RoughAnnotationConfig): FullPadding {
|
||||
return [5, 5, 5, 5];
|
||||
}
|
||||
|
||||
export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAnnotationConfig, animationGroupDelay: number, seed: number) {
|
||||
export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAnnotationConfig, animationGroupDelay: number, animationDuration: number, seed: number) {
|
||||
const opList: OpSet[] = [];
|
||||
let strokeWidth = config.strokeWidth || 2;
|
||||
const padding = parsePadding(config);
|
||||
@@ -156,7 +156,6 @@ export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAn
|
||||
const lengths: number[] = [];
|
||||
const pathElements: SVGPathElement[] = [];
|
||||
let totalLength = 0;
|
||||
const totalDuration = config.animationDuration === 0 ? 0 : (config.animationDuration || DEFAULT_ANIMATION_DURATION);
|
||||
const setAttr = (p: SVGPathElement, an: string, av: string) => p.setAttribute(an, av);
|
||||
|
||||
for (const d of pathStrings) {
|
||||
@@ -179,7 +178,7 @@ export function renderAnnotation(svg: SVGSVGElement, rect: Rect, config: RoughAn
|
||||
for (let i = 0; i < pathElements.length; i++) {
|
||||
const path = pathElements[i];
|
||||
const length = lengths[i];
|
||||
const duration = totalLength ? (totalDuration * (length / totalLength)) : 0;
|
||||
const duration = totalLength ? (animationDuration * (length / totalLength)) : 0;
|
||||
const delay = animationGroupDelay + durationOffset;
|
||||
const style = path.style;
|
||||
style.strokeDashoffset = `${length}`;
|
||||
|
||||
@@ -216,9 +216,9 @@ class RoughAnnotationImpl implements RoughAnnotation {
|
||||
let delay = 0;
|
||||
for (let i = 0; i < rects.length; i++) {
|
||||
const rect = rects[i];
|
||||
config.animationDuration = totalDuration * (rect.w / totalWidth);
|
||||
renderAnnotation(svg, rects[i], config, delay + this._animationDelay, this._seed);
|
||||
delay += config.animationDuration;
|
||||
const ad = totalDuration * (rect.w / totalWidth);
|
||||
renderAnnotation(svg, rects[i], config, delay + this._animationDelay, ad, this._seed);
|
||||
delay += ad;
|
||||
}
|
||||
this._lastSizes = rects;
|
||||
this._state = 'showing';
|
||||
|
||||
Reference in New Issue
Block a user