Skip to content

Commit

Permalink
v0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chanind committed Feb 5, 2018
1 parent fddfb23 commit c7ff224
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
26 changes: 20 additions & 6 deletions dist/hanzi-writer-lib.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Hanzi Writer v0.5.0
* Hanzi Writer v0.5.1
* https://chanind.github.io/hanzi-writer
*/
module.exports =
Expand Down Expand Up @@ -447,6 +447,8 @@ function StyleTween(elm, style, endValue) {
this._elm = elm;
this._style = style;
this._endValue = endValue;
// ensureEndStyle is if the tween is canceled early, should elm style be set immediately to endValue?
this._ensureEndStyle = options.ensureEndStyle;
}
inherits(StyleTween, Tween);

Expand All @@ -458,6 +460,13 @@ StyleTween.prototype.start = function () {
return StyleTween.super_.prototype.start.call(this);
};

StyleTween.prototype.finish = function () {
if (this._isActive && this._ensureEndStyle) {
this._elm.style[this._style] = this._endValue;
}
return StyleTween.super_.prototype.finish.call(this);
};

// -------- CANVAS CLASS --------

function Canvas(svg, defs) {
Expand Down Expand Up @@ -490,6 +499,10 @@ Canvas.init = function (elmOrId) {
return new Canvas(svg, defs);
};

Canvas.prototype.remove = function () {
this.svg.parentNode.removeChild(this.svg);
};

module.exports = { createElm: createElm, attrs: attrs, attr: attr, Canvas: Canvas, Tween: Tween, StyleTween: StyleTween, getPathString: getPathString };
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))

Expand Down Expand Up @@ -767,8 +780,7 @@ HanziWriter.prototype._loadCharacterData = function (char) {
};

HanziWriter.prototype._withData = function (func) {
this._withDataPromise = this._withDataPromise.then(func);
return this._withDataPromise;
return this._withDataPromise.then(func);
};

HanziWriter.prototype._setupListeners = function () {
Expand Down Expand Up @@ -1085,15 +1097,17 @@ StrokeRenderer.prototype.show = function (animation) {
this.maskPath.style['stroke-dashoffset'] = 0;
}
var tween = new svg.StyleTween(this.path, 'opacity', 1, {
duration: this.options.strokeFadeDuration
duration: this.options.strokeFadeDuration,
ensureEndStyle: true
});
animation.registerSvgAnimation(tween);
return tween.start();
};

StrokeRenderer.prototype.hide = function (animation) {
var tween = new svg.StyleTween(this.path, 'opacity', 0, {
duration: this.options.strokeFadeDuration
duration: this.options.strokeFadeDuration,
ensureEndStyle: true
});
animation.registerSvgAnimation(tween);
return tween.start();
Expand Down Expand Up @@ -1601,7 +1615,7 @@ Quiz.prototype.endUserStroke = function () {
_this._userStrokeRenderer = null;

if (isMatch) {
_this._handleSuccess(nextStroke, animation);
promises.push(_this._handleSuccess(nextStroke, animation));
} else {
_this._handleFailure();
if (_this._numRecentMistakes >= _this._quizOptions.showHintAfterMisses) {
Expand Down
4 changes: 2 additions & 2 deletions dist/hanzi-writer-lib.min.js

Large diffs are not rendered by default.

26 changes: 20 additions & 6 deletions dist/hanzi-writer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Hanzi Writer v0.5.0
* Hanzi Writer v0.5.1
* https://chanind.github.io/hanzi-writer
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -446,6 +446,8 @@ function StyleTween(elm, style, endValue) {
this._elm = elm;
this._style = style;
this._endValue = endValue;
// ensureEndStyle is if the tween is canceled early, should elm style be set immediately to endValue?
this._ensureEndStyle = options.ensureEndStyle;
}
inherits(StyleTween, Tween);

Expand All @@ -457,6 +459,13 @@ StyleTween.prototype.start = function () {
return StyleTween.super_.prototype.start.call(this);
};

StyleTween.prototype.finish = function () {
if (this._isActive && this._ensureEndStyle) {
this._elm.style[this._style] = this._endValue;
}
return StyleTween.super_.prototype.finish.call(this);
};

// -------- CANVAS CLASS --------

function Canvas(svg, defs) {
Expand Down Expand Up @@ -489,6 +498,10 @@ Canvas.init = function (elmOrId) {
return new Canvas(svg, defs);
};

Canvas.prototype.remove = function () {
this.svg.parentNode.removeChild(this.svg);
};

module.exports = { createElm: createElm, attrs: attrs, attr: attr, Canvas: Canvas, Tween: Tween, StyleTween: StyleTween, getPathString: getPathString };
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))

Expand Down Expand Up @@ -766,8 +779,7 @@ HanziWriter.prototype._loadCharacterData = function (char) {
};

HanziWriter.prototype._withData = function (func) {
this._withDataPromise = this._withDataPromise.then(func);
return this._withDataPromise;
return this._withDataPromise.then(func);
};

HanziWriter.prototype._setupListeners = function () {
Expand Down Expand Up @@ -1084,15 +1096,17 @@ StrokeRenderer.prototype.show = function (animation) {
this.maskPath.style['stroke-dashoffset'] = 0;
}
var tween = new svg.StyleTween(this.path, 'opacity', 1, {
duration: this.options.strokeFadeDuration
duration: this.options.strokeFadeDuration,
ensureEndStyle: true
});
animation.registerSvgAnimation(tween);
return tween.start();
};

StrokeRenderer.prototype.hide = function (animation) {
var tween = new svg.StyleTween(this.path, 'opacity', 0, {
duration: this.options.strokeFadeDuration
duration: this.options.strokeFadeDuration,
ensureEndStyle: true
});
animation.registerSvgAnimation(tween);
return tween.start();
Expand Down Expand Up @@ -1600,7 +1614,7 @@ Quiz.prototype.endUserStroke = function () {
_this._userStrokeRenderer = null;

if (isMatch) {
_this._handleSuccess(nextStroke, animation);
promises.push(_this._handleSuccess(nextStroke, animation));
} else {
_this._handleFailure();
if (_this._numRecentMistakes >= _this._quizOptions.showHintAfterMisses) {
Expand Down
4 changes: 2 additions & 2 deletions dist/hanzi-writer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hanzi-writer",
"version": "0.5.0",
"version": "0.5.1",
"author": "David Chanin <chanindav@gmail.com> (http://chanind.github.io/hanzi-writer/)",
"description": "Hanzi Writer is a free and open-source javascript library for both animating simplified Chinese characters and quizzing users on character stroke order.",
"repository": "chanind/hanzi-writer",
Expand Down

0 comments on commit c7ff224

Please sign in to comment.