Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 70053ae

Browse files
committed
Merge pull request #7248 from SAPlayer/inline-timing-function-editor-fadeout-fix
[BezierEditor] Fix fadeout issue
2 parents c52bffe + ae1b669 commit 70053ae

3 files changed

Lines changed: 30 additions & 25 deletions

File tree

src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,14 @@ define(function (require, exports, module) {
530530
// current cubic-bezier() function params
531531
this._cubicBezierCoords = this._getCubicBezierCoords(bezierCurve);
532532

533-
this.hint = $(".hint", this.$element);
533+
this.hint = {};
534+
this.hint.elem = $(".hint", this.$element);
534535
// If function was auto-corrected, then originalString holds the original function,
535536
// and an informational message needs to be shown
536537
if (bezierCurve.originalString) {
537-
TimingFunctionUtils.showHideHint(this, true, bezierCurve.originalString, "cubic-bezier(" + this._cubicBezierCoords.join(", ") + ")");
538+
TimingFunctionUtils.showHideHint(this.hint, true, bezierCurve.originalString, "cubic-bezier(" + this._cubicBezierCoords.join(", ") + ")");
538539
} else {
539-
TimingFunctionUtils.showHideHint(this, false);
540+
TimingFunctionUtils.showHideHint(this.hint, false);
540541
}
541542

542543
this.P1 = this.$element.find(".P1")[0];
@@ -611,7 +612,7 @@ define(function (require, exports, module) {
611612
this._cubicBezierCoords[2] + ", " +
612613
this._cubicBezierCoords[3] + ")";
613614
this._callback(bezierCurveVal);
614-
TimingFunctionUtils.showHideHint(this, false);
615+
TimingFunctionUtils.showHideHint(this.hint, false);
615616
};
616617

617618
/**
@@ -697,9 +698,9 @@ define(function (require, exports, module) {
697698
// If function was auto-corrected, then originalString holds the original function,
698699
// and an informational message needs to be shown
699700
if (bezierCurve.originalString) {
700-
TimingFunctionUtils.showHideHint(this, true, bezierCurve.originalString, "cubic-bezier(" + this._cubicBezierCoords.join(", ") + ")");
701+
TimingFunctionUtils.showHideHint(this.hint, true, bezierCurve.originalString, "cubic-bezier(" + this._cubicBezierCoords.join(", ") + ")");
701702
} else {
702-
TimingFunctionUtils.showHideHint(this, false);
703+
TimingFunctionUtils.showHideHint(this.hint, false);
703704
}
704705
};
705706

src/extensions/default/InlineTimingFunctionEditor/StepEditor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,14 @@ define(function (require, exports, module) {
310310
// current step function params
311311
this._stepParams = this._getStepParams(stepMatch);
312312

313-
this.hint = $(".hint", this.$element);
313+
this.hint = {};
314+
this.hint.elem = $(".hint", this.$element);
314315
// If function was auto-corrected, then originalString holds the original function,
315316
// and an informational message needs to be shown
316317
if (stepMatch.originalString) {
317-
TimingFunctionUtils.showHideHint(this, true, stepMatch.originalString, "steps(" + this._stepParams.count.toString() + ", " + this._stepParams.timing + ")");
318+
TimingFunctionUtils.showHideHint(this.hint, true, stepMatch.originalString, "steps(" + this._stepParams.count.toString() + ", " + this._stepParams.timing + ")");
318319
} else {
319-
TimingFunctionUtils.showHideHint(this, false);
320+
TimingFunctionUtils.showHideHint(this.hint, false);
320321
}
321322

322323
this.canvas = this.$element.find(".steps")[0];
@@ -364,7 +365,7 @@ define(function (require, exports, module) {
364365
this._stepParams.count.toString() + ", " +
365366
this._stepParams.timing + ")";
366367
this._callback(stepFuncVal);
367-
TimingFunctionUtils.showHideHint(this, false);
368+
TimingFunctionUtils.showHideHint(this.hint, false);
368369
};
369370

370371
/**
@@ -436,9 +437,9 @@ define(function (require, exports, module) {
436437
// If function was auto-corrected, then originalString holds the original function,
437438
// and an informational message needs to be shown
438439
if (stepMatch.originalString) {
439-
TimingFunctionUtils.showHideHint(this, true, stepMatch.originalString, "steps(" + this._stepParams.count.toString() + ", " + this._stepParams.timing + ")");
440+
TimingFunctionUtils.showHideHint(this.hint, true, stepMatch.originalString, "steps(" + this._stepParams.count.toString() + ", " + this._stepParams.timing + ")");
440441
} else {
441-
TimingFunctionUtils.showHideHint(this, false);
442+
TimingFunctionUtils.showHideHint(this.hint, false);
442443
}
443444
};
444445

src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,31 +248,34 @@ define(function (require, exports, module) {
248248
/**
249249
* Show, hide or update the hint text
250250
*
251-
* @param {(BezierCurveEditor|StepEditor)} editor BezierCurveEditor or StepsEditor where the hint should be changed
251+
* @param {object} hint Editor.hint object of the current InlineTimingFunctionEditor
252252
* @param {boolean} show Whether the hint should be shown or hidden
253253
* @param {string=} documentCode The invalid code from the document (can be omitted when hiding)
254254
* @param {string=} editorCode The valid code that is shown in the Inline Editor (can be omitted when hiding)
255255
*/
256-
function showHideHint(editor, show, documentCode, editorCode) {
257-
if (!editor.hint) {
256+
function showHideHint(hint, show, documentCode, editorCode) {
257+
if (!hint || !hint.elem) {
258258
return;
259259
}
260260

261-
$(editor.hint[0]).removeClass("fadeout");
262261
if (show) {
263-
editor.hintShown = true;
264-
editor.hint.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
265-
editor.hint.css("display", "block");
266-
} else if (editor.hintShown) {
267-
editor.hintShown = false;
268-
AnimationUtils.animateUsingClass(editor.hint[0], "fadeout")
262+
hint.shown = true;
263+
hint.animationInProgress = false;
264+
hint.elem.removeClass("fadeout");
265+
hint.elem.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
266+
hint.elem.css("display", "block");
267+
} else if (hint.shown) {
268+
hint.animationInProgress = true;
269+
AnimationUtils.animateUsingClass(hint.elem[0], "fadeout")
269270
.done(function () {
270-
if (!editor.hintShown) {
271-
editor.hint.css("display", "none");
271+
if (hint.animationInProgress) { // do this only if the animation was not cancelled
272+
hint.elem.hide();
272273
}
274+
hint.shown = false;
275+
hint.animationInProgress = false;
273276
});
274277
} else {
275-
editor.hint.css("display", "none");
278+
hint.elem.hide();
276279
}
277280
}
278281

0 commit comments

Comments
 (0)