258 Commits

Author SHA1 Message Date
zcrkey
83a762374e fix: Replace performance.now() with performanceNow() for consistent timing (#334) 2025-12-31 00:43:32 -05:00
David Chanin
55db187425 chore: Add CITATION.cff for software citation information 2025-10-12 19:43:56 -04:00
Jonathan Moore
7cff0a3897 perf: Use full semver (hanzi-writer-data@2.0.1) to take advantage of jsdelivr long-term Cache-Control (#328) v3.7.3 2025-09-17 16:23:22 -04:00
Phong Phan
7850090910 fix: bind requestAnimationFrame and cancelAnimationFrame to window context (#322) v3.7.2 2024-11-13 06:10:48 -05:00
Polo
22cafa679a fix: Ensure consistent stroke drawing in quiz mode on mobile (#320)
* Fix touchmove stops in the middle of a stroke

* Fix tests with new way of removing strokes
v3.7.1
2024-09-22 14:13:03 -04:00
Valentin Herrmann
b5c0d3910b feat: Added skipQuizStroke (#317)
* feat: Added skipStrokeQuiz

* adding tests and tweaking API

---------

Co-authored-by: David Chanin <chanindav@gmail.com>
v3.7.0
2024-05-23 03:56:12 -04:00
David Chanin
4ec4edaeee chore: remove bundlephobia from README as it seems to be down 2024-02-12 05:41:46 -05:00
David Chanin
71de0598e9 fix: add license info to package.json v3.6.1 2024-01-02 10:53:04 -05:00
Rozstone
1682d83907 feat: Add averageDistanceThreshold Option for Stroke Matching Leniency (#307)
* replace AVG_DIST_THRESHOLD constant with configurable option

* fix trailing comma
v3.6.0
2023-09-15 08:28:44 -04:00
David Chanin
319ea837c2 feat: adding markStrokeCorrectAfterMisses option to quizzes (#295) v3.5.0 2023-02-09 07:41:53 -05:00
David Chanin
13852e7d42 fix: hide stroke highlight if it gets canceled rather than leaving it halfway (#294) v3.4.2 2023-02-08 13:39:48 -05:00
David Chanin
99c6f93ef8 fix: respect highlightCompleteColor when finishing quiz (#293) v3.4.1 2023-02-08 12:48:17 -05:00
David Chanin
c0c08b0083 feat: add quizStartStrokeNum option to allow quizzing final stroke (#281) v3.4.0 2022-10-26 06:36:23 -04:00
Matt Tingen
15d37e8a28 feat: allow checking backwards strokes (#252)
* feat: allow checking backwards strokes

* fixup: fix getMatchData types

Because it is recursive, it requires an explicit return type annotation.

* fixup: add single point test case

* fixup: avoid ternary values
v3.3.0
2021-10-02 17:22:51 +01:00
David Chanin
f1a810c471 feat: adding writer.updateDimensions method (#245)
* adding a method to updateDimensions of an existing writer without replacing state

* reorganizing methods

* updating caniuse to keep tests happy

* adding a setPositioner test to keep codecov happy
v3.2.0
2021-07-12 15:52:34 +01:00
David Chanin
3766a8bccc feat: adding a getCharacterData() method for easier loading of character data (#223) v3.1.0 2021-03-02 21:13:53 +00:00
David Chanin
9384f1cc4e fix: support older node and browser versions (#221) v3.0.3 2021-02-24 12:14:14 +00:00
David Chanin
9b332248d3 fix: escaping the URL passed to clip-path to handle parentheses (#217)
Fixing a bug where if the current page has parentheses in the URL, it would cause hanzi-writer to break. Thanks @ cqiangcode for finding this!
v3.0.2
2021-02-01 20:39:20 +00:00
jamsch
009be80b7a fix: type exports (#214)
* Fix types bundle artifact for RecursivePartial
Properly export PositionerOptions
Bump packages

* update(types) allow PositionerOptions (in HanziWriterOptions) to be optional

* update(package.json) downgrade jest-canvas-mock to fix broken tests
v3.0.1
2021-01-19 00:40:59 +00:00
David Chanin
48f5037606 feat(types): Typescript rewrite (#211)
BREAKING CHANGE: Full rewrite in typescript, deprecated constructor args are removed

* [ts-migrate][src] Init tsconfig.json file

Co-authored-by: ts-migrate <>

* [ts-migrate][src] Rename files from JS/JSX to TS/TSX

Co-authored-by: ts-migrate <>

* [ts-migrate][src] Run TS Migrate

Co-authored-by: ts-migrate <>

* Convert project in to typescript

* update(UserStrokeRenderer) add typings

* update(jest-setup) replace (deprecated) lolex with "@sinonjs/fake-timers"

* move tsconfig to root dir

* Type additions, fixes, test updates

* Update typings

* Configure rollup for deployment

* fix tests & linting

* Include declaration types in build

* update(Mutation) Implement type checks for provided mutation values based on the RenderState class/object
- This makes the mutation a bit more verbose as it gets rid of the _inflate() call
- There's no longer a need to provide a scope (unless you'd like to manually cancel mutations)
- Optimise the cancelAll() function

* update(utils) remove inflate() function as it's no longer needed

* update(typings) allow users to import typedefs from "hanzi-writer"

* chore: bump package versions

* update(demo) fix default "showCharacter" state

* Strengthen typings

* Update lint config

* update(Mutation) edge case for handling "isAlreadyAtEnd" where startValue may be undefined

* update(HanziWriter) handle edge case where "_withDataPromise" may not be set

* update(HanziWriter) add "resetDisplay" in cancelQuiz to allow users to reset their show/hide" character/outline options when manually cancelling.

* update(tests) add "quiz.cancelTest({ resetDisplay: bool })" tests

* update(HanziWriter) write tests for "_loadingManager" singleton

* Remove webpack config

* update(Quiz) add "onHighlightComplete" to quiz options
This allows UI updates after the highlight has finished.

* Add example using react (with typescript)
Move vanilla js example from "demo" in to "examples" dir

* update(Positioner) Require options with non-null values

* update(Quiz & strokeMatches) apply cleanups, move default export to top of file

* update(HanziWriter) don't return mutations

* General file cleanups

* update(project) Configure ts plugin to use babel transpiler
- add filesize plugin
- remove babel 6 packages
- remove webpack

* update(types) Loosen type requirement of CharacterJson to avoid type assertions.

* fix(mutations) Quiz highlight complete color should now work correctly.

Seems to be two sources of truth for display stroke colors in RenderStateObject: "character[xxx].strokeColor" & "options.xxxxColor". The former never was never used so this has now been removed from the render state object.

* Update quiz tests

* Update using-react example

* fix(CharacterActions) race condition between highlightStroke & showStroke where highlight opacity doesn't reset

* update(tests) add svg/RenderTarget tests

* fix typo

* update(tests) Add more RenderTarget tests
bump packages

* bump packages

* remove unused types package

* Update snapshots

* fix(geometry) stack overflow executing the frechetDist function on complex paths

Had some error logs that involve stack overflows originating from `recursiveCalc`. Rather opt for an O(n^2) algo.

* update(circleci/config.yml) node version to v14 LTS

* singlequote prettier style

* recreating old tests to ensure functionality has not changed

* removing examples to reduce scope of changes

* adding back demo from master branch

* fixing up imports and revertin cancelQuiz style to match master

* reverting closer to master

* reverting closer to master

* changing cov target to 96

* fixing types

* minor reversions

* updating package.json version

Co-authored-by: James <jamsch18@student.wintec.ac.nz>
Co-authored-by: James S <jschafli@hotmail.com>
v3.0.0
2021-01-18 22:16:57 +00:00
David Chanin
3ebc504e4d feat: release v2.3.0 2020-10-03 11:27:16 +01:00
jamsch
fd8c2e6b88 fix(Quiz) Don't highlight stroke when setting "showHintAfterMisses" to false (#187)
* fix(Quiz) Don't highlight stroke when setting "showHintAfterMisses" to false

* update(Quiz-test) add "showHintAfterMisses: false" test

* update(Quiz-test) fix lint error
2020-09-14 13:57:09 +01:00
jamsch
2f9f09ebfa update(Quiz) remove unused function param in "_handleSuccess" (#189) 2020-09-14 13:54:50 +01:00
jamsch
4f7e7c70b7 update(HanziWriter) remove undef variable "this.isLoadingCharData" (#190) 2020-09-14 13:53:12 +01:00
jamsch
6764ef538a update(HanziWriterRenderer) remove extra param on .mount() call (#192) 2020-09-14 13:52:11 +01:00
jamsch
66e807d28f update(Quiz) remove unused var "this._drawnStrokes" (#191) 2020-09-14 13:51:01 +01:00
David Chanin
5f9370d8c2 fix: bump for release v2.2.2 2020-03-05 20:15:45 +00:00
chanind
2f136f9fed fix IE/Edge SVG animation bug (#165) 2020-03-05 20:10:54 +00:00
dependabot[bot]
be6bb601ac Bump codecov from 3.5.0 to 3.6.5 (#159)
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.5.0 to 3.6.5.
- [Release notes](https://github.com/codecov/codecov-node/releases)
- [Commits](https://github.com/codecov/codecov-node/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-02-25 20:01:07 +00:00
chanind
2e6b884aec fix: better error message if render target not found (#161) v2.2.1 2020-02-25 19:59:45 +00:00
David Chanin
bc790f13dd chore: fixing comment about cdn source 2020-01-13 22:22:36 +00:00
chanind
ed7fe1bfa4 feat: pauseAnimation and resumeAnimation (#156)
* feat: adding pauseAnimation and resumeAnimation

* fixing linting
v2.2.0
2020-01-12 16:43:34 +00:00
chanind
56e6906ecd feat: adding writer.highlightStroke() method (#146)
* feat: adding writer.highlightStroke() method

* fixing linting
v2.1.0
2019-11-10 13:08:49 +00:00
David Chanin
864479005d fix: updating test snapshots for #130 v2.0.4 2019-08-01 07:54:24 +01:00
kevin82008
b4e8087303 解决ios系统无法显示汉字动画的问题 (#130)
* 解决ios系统无法显示汉字动画的问题

* delete  Multiple spaces
2019-08-01 07:53:30 +01:00
David Chanin
943c61791e fix: bump to push release 2.0.3 v2.0.3 2019-07-31 22:16:51 +01:00
chanind
5f3c1fc251 fix bug with calling setCharacter multiple times quickly (#131) 2019-07-31 22:10:49 +01:00
dependabot[bot]
7c0bbddaa5 Bump lodash from 4.17.11 to 4.17.14 (#127)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.14)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-31 18:32:57 +01:00
David Chanin
1fe6e9cbf6 fix: version bump to latest v2.0.2 2019-06-11 13:41:24 +01:00
chanind
677fea40d3 fix: fixing bug in getting SVG mouse/touch points v2.0.1 2019-06-11 11:22:23 +01:00
chanind
091f409fb2 feat: setting up semantic-release (#118)
BREAKING CHANGE: noConflict has been removed
v2.0.0
2019-06-10 22:05:50 +01:00
Tom MacWright
3e63e81141 Umd build extra (#117)
* Build UMD package and use a variable-safe library name

* Single build

* test: Remove noConflict test, add dist to .gitignore
2019-06-10 21:50:06 +01:00
David Chanin
c4836f7bcf v1.4.2 v1.4.2 2019-06-09 21:31:09 +01:00
David Chanin
4810c1a0db v1.4.2 2019-06-09 21:30:29 +01:00
chanind
442add07e7 Rendering refactor in preparation for Wechat Miniprogram support (#114)
* Building a POC for miniprogram rendering

* fixing snapshot test

* removing wechat renderer code and adding tests

* refactoring event listeners into RenderTarget

* tweaking abstractions to allow Miniprogram rendering
2019-06-09 21:27:36 +01:00
David Chanin
a034e0fb86 removing unused dev dependency 2019-06-08 12:38:47 +01:00
David Chanin
3307199625 updating npmignore v1.4.1 2019-06-02 14:58:29 +01:00
David Chanin
446356e660 v1.4.1 2019-06-02 14:55:27 +01:00
David Chanin
3a39c7c33d updating npmignore v1.4.0 2019-06-02 14:52:25 +01:00
David Chanin
cf27ca3cfa v1.4.0 2019-06-02 14:47:54 +01:00