mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
fix(demos): debounce setRoot call
This commit is contained in:
@ -68,3 +68,18 @@ export function getPageFor(hash) {
|
||||
'tabs': TabsPage
|
||||
}[hash]
|
||||
}
|
||||
|
||||
export function debounce(func, wait, immediate) {
|
||||
var timeout;
|
||||
return function() {
|
||||
var context = this, args = arguments;
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
};
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ class DemoApp {
|
||||
this.nextPage = ActionSheetPage;
|
||||
}
|
||||
let nav = this.app.getComponent('nav');
|
||||
nav.setRoot(this.nextPage);
|
||||
helpers.debounce(nav.setRoot(this.nextPage), 100, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user