Skip to content

Commit 5b17141

Browse files
authored
Merge pull request #19 from swup/fix-timeout
Fix timeout issues
2 parents 4bd45ff + f5f7158 commit 5b17141

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

dist/SwupProgressPlugin.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -164,33 +164,39 @@ var SwupProgressPlugin = function (_Plugin) {
164164
} else {
165165
_this.finishAnimationAndHideProgressBar();
166166
}
167-
168-
if (_this.showProgressBarTimeout != null) {
169-
window.clearTimeout(_this.showProgressBarTimeout);
170-
delete _this.showProgressBarTimeout;
171-
}
172167
};
173168

174169
_this.showProgressBar = function () {
175-
if (_this.hideProgressBarTimeout != null) {
176-
window.clearTimeout(_this.hideProgressBarTimeout);
177-
delete _this.hideProgressBarTimeout;
178-
}
170+
_this.cancelHideProgressBarTimeout();
179171
_this.progressBar.show();
180172
};
181173

182174
_this.showProgressBarAfterDelay = function () {
175+
_this.cancelShowProgressBarTimeout();
176+
_this.cancelHideProgressBarTimeout();
183177
_this.showProgressBarTimeout = window.setTimeout(_this.showProgressBar, _this.options.delay);
184178
};
185179

186180
_this.hideProgressBar = function () {
181+
_this.cancelShowProgressBarTimeout();
187182
_this.progressBar.hide();
188183
};
189184

190185
_this.finishAnimationAndHideProgressBar = function () {
186+
_this.cancelShowProgressBarTimeout();
191187
_this.hideProgressBarTimeout = window.setTimeout(_this.hideProgressBar, _this.options.transition);
192188
};
193189

190+
_this.cancelShowProgressBarTimeout = function () {
191+
window.clearTimeout(_this.showProgressBarTimeout);
192+
delete _this.showProgressBarTimeout;
193+
};
194+
195+
_this.cancelHideProgressBarTimeout = function () {
196+
window.clearTimeout(_this.hideProgressBarTimeout);
197+
delete _this.hideProgressBarTimeout;
198+
};
199+
194200
var defaultOptions = {
195201
className: 'swup-progress-bar',
196202
delay: 300,
@@ -203,6 +209,7 @@ var SwupProgressPlugin = function (_Plugin) {
203209
_this.options = _extends({}, defaultOptions, options);
204210

205211
_this.showProgressBarTimeout = null;
212+
_this.hideProgressBarTimeout = null;
206213

207214
_this.progressBar = new _ProgressBar2.default({
208215
className: _this.options.className,

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)