Skip to content

Commit c92712d

Browse files
authored
Finish the animation before hiding the progress bar (#7)
* Finish the animation before hiding the progress bar * Add new option `hideImmediately`
1 parent 90d319d commit c92712d

File tree

4 files changed

+7849
-38
lines changed

4 files changed

+7849
-38
lines changed

dist/SwupProgressPlugin.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -157,34 +157,48 @@ var SwupProgressPlugin = function (_Plugin) {
157157

158158
_this.stopShowingProgress = function () {
159159
_this.progressBar.setValue(1);
160-
_this.hideProgressBar();
160+
if (_this.options.hideImmediately) {
161+
_this.hideProgressBar();
162+
} else {
163+
_this.finishAnimationAndHideProgressBar();
164+
}
161165
};
162166

163167
_this.showProgressBar = function () {
168+
if (_this.hideProgressBarTimeout != null) {
169+
window.clearTimeout(_this.hideProgressBarTimeout);
170+
delete _this.hideProgressBarTimeout;
171+
}
164172
_this.progressBar.show();
165173
};
166174

167175
_this.showProgressBarAfterDelay = function () {
168-
_this.progressBarTimeout = window.setTimeout(_this.showProgressBar, _this.options.delay);
176+
_this.showProgressBarTimeout = window.setTimeout(_this.showProgressBar, _this.options.delay);
169177
};
170178

171179
_this.hideProgressBar = function () {
172180
_this.progressBar.hide();
173-
if (_this.progressBarTimeout != null) {
174-
window.clearTimeout(_this.progressBarTimeout);
175-
delete _this.progressBarTimeout;
181+
};
182+
183+
_this.finishAnimationAndHideProgressBar = function () {
184+
_this.hideProgressBarTimeout = window.setTimeout(_this.hideProgressBar, _this.options.transition);
185+
186+
if (_this.showProgressBarTimeout != null) {
187+
window.clearTimeout(_this.showProgressBarTimeout);
188+
delete _this.showProgressBarTimeout;
176189
}
177190
};
178191

179192
var defaultOptions = {
180193
className: 'swup-progress-bar',
181194
transition: 300,
182-
delay: 300
195+
delay: 300,
196+
hideImmediately: true
183197
};
184198

185199
_this.options = _extends({}, defaultOptions, options);
186200

187-
_this.progressBarTimeout = null;
201+
_this.showProgressBarTimeout = null;
188202
_this.progressBar = new _ProgressBar2.default({
189203
className: _this.options.className,
190204
animationDuration: _this.options.transition

dist/SwupProgressPlugin.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)