#567 reset scroll before config runs
This commit is contained in:
parent
b847ca1067
commit
cc8cac358a
1 changed files with 8 additions and 4 deletions
12
mithril.js
12
mithril.js
|
|
@ -545,7 +545,7 @@ var m = (function app(window, undefined) {
|
||||||
return gettersetter(store)
|
return gettersetter(store)
|
||||||
};
|
};
|
||||||
|
|
||||||
var roots = [], components = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePostRedrawHook = null, prevented = false, topComponent, unloaders = [];
|
var roots = [], components = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePreRedrawHook = null, computePostRedrawHook = null, prevented = false, topComponent, unloaders = [];
|
||||||
var FRAME_BUDGET = 16; //60 frames per second = 1 call per 16 ms
|
var FRAME_BUDGET = 16; //60 frames per second = 1 call per 16 ms
|
||||||
function parameterize(component, args) {
|
function parameterize(component, args) {
|
||||||
var controller = function() {
|
var controller = function() {
|
||||||
|
|
@ -600,7 +600,7 @@ var m = (function app(window, undefined) {
|
||||||
endFirstComputation();
|
endFirstComputation();
|
||||||
return controllers[index]
|
return controllers[index]
|
||||||
}
|
}
|
||||||
else computePostRedrawHook = null
|
else computePreRedrawHook = computePostRedrawHook = null
|
||||||
};
|
};
|
||||||
var redrawing = false
|
var redrawing = false
|
||||||
m.redraw = function(force) {
|
m.redraw = function(force) {
|
||||||
|
|
@ -624,6 +624,10 @@ var m = (function app(window, undefined) {
|
||||||
};
|
};
|
||||||
m.redraw.strategy = m.prop();
|
m.redraw.strategy = m.prop();
|
||||||
function redraw() {
|
function redraw() {
|
||||||
|
if (computePreRedrawHook) {
|
||||||
|
computePreRedrawHook()
|
||||||
|
computePreRedrawHook = null
|
||||||
|
}
|
||||||
for (var i = 0, root; root = roots[i]; i++) {
|
for (var i = 0, root; root = roots[i]; i++) {
|
||||||
if (controllers[i]) {
|
if (controllers[i]) {
|
||||||
var args = components[i].controller && components[i].controller.$$args ? [controllers[i]].concat(components[i].controller.$$args) : [controllers[i]]
|
var args = components[i].controller && components[i].controller.$$args ? [controllers[i]].concat(components[i].controller.$$args) : [controllers[i]]
|
||||||
|
|
@ -685,7 +689,7 @@ var m = (function app(window, undefined) {
|
||||||
redirect(path)
|
redirect(path)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
computePostRedrawHook = setScroll;
|
computePreRedrawHook = setScroll;
|
||||||
window[listener]()
|
window[listener]()
|
||||||
}
|
}
|
||||||
//config: m.route
|
//config: m.route
|
||||||
|
|
@ -718,9 +722,9 @@ var m = (function app(window, undefined) {
|
||||||
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || oldRoute === arguments[0];
|
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || oldRoute === arguments[0];
|
||||||
|
|
||||||
if (window.history.pushState) {
|
if (window.history.pushState) {
|
||||||
|
computePreRedrawHook = setScroll
|
||||||
computePostRedrawHook = function() {
|
computePostRedrawHook = function() {
|
||||||
window.history[shouldReplaceHistoryEntry ? "replaceState" : "pushState"](null, $document.title, modes[m.route.mode] + currentRoute);
|
window.history[shouldReplaceHistoryEntry ? "replaceState" : "pushState"](null, $document.title, modes[m.route.mode] + currentRoute);
|
||||||
setScroll()
|
|
||||||
};
|
};
|
||||||
redirect(modes[m.route.mode] + currentRoute)
|
redirect(modes[m.route.mode] + currentRoute)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue