Skip to content

Commit

Permalink
fix: 无变化跳出遗漏 #104
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Nov 3, 2020
1 parent 7c69ded commit 4bae6ca
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 48 deletions.
52 changes: 29 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3861,7 +3861,7 @@
parent = node.parent;
var parentComputedStyle = !isHost && parent.computedStyle;
o.MEASURE_KEY_SET.forEach(function (k) {
var v = currentStyle[k]; // console.log(node.tagName, k, v);
var v = currentStyle[k];

if (v.unit === INHERIT$1) {
computedStyle[k] = isHost ? reset.INHERIT[k] : parentComputedStyle[k];
Expand Down Expand Up @@ -9211,25 +9211,27 @@
function getEasing(ea) {
var timingFunction;

if (/^\s*(?:cubic-bezier\s*)?\(\s*[\d.]+\s*,\s*[-\d.]+\s*,\s*[\d.]+\s*,\s*[-\d.]+\s*\)\s*$/i.test(ea)) {
var v = ea.match(/[\d.]+/g);
timingFunction = easing.cubicBezier(v[0], v[1], v[2], v[3]);
} else if (timingFunction = /^\s*steps\s*\(\s*(\d+)(?:\s*,\s*(\w+))?\s*\)/i.exec(ea)) {
var steps = parseInt(timingFunction[1]);
var stepsD = timingFunction[2];
if (ea) {
if (/^\s*(?:cubic-bezier\s*)?\(\s*[\d.]+\s*,\s*[-\d.]+\s*,\s*[\d.]+\s*,\s*[-\d.]+\s*\)\s*$/i.test(ea)) {
var v = ea.match(/[\d.]+/g);
timingFunction = easing.cubicBezier(v[0], v[1], v[2], v[3]);
} else if (timingFunction = /^\s*steps\s*\(\s*(\d+)(?:\s*,\s*(\w+))?\s*\)/i.exec(ea)) {
var steps = parseInt(timingFunction[1]);
var stepsD = timingFunction[2];

timingFunction = function timingFunction(percent) {
// steps有效定义正整数
if (steps && steps > 0) {
var per = 1 / steps;
var n = stepsD === 'start' ? Math.ceil(percent / per) : Math.floor(percent / per);
return n / steps;
}
timingFunction = function timingFunction(percent) {
// steps有效定义正整数
if (steps && steps > 0) {
var per = 1 / steps;
var n = stepsD === 'start' ? Math.ceil(percent / per) : Math.floor(percent / per);
return n / steps;
}

return percent;
};
} else {
timingFunction = easing[ea] || linear;
return percent;
};
} else {
timingFunction = easing[ea];
}
}

return timingFunction;
Expand All @@ -9248,7 +9250,7 @@
var style = clone$1(frame.style);
var timingFunction = getEasing(frame.easing);

if (timingFunction !== linear) {
if (timingFunction && timingFunction !== linear) {
percent = timingFunction(percent);
}

Expand Down Expand Up @@ -19437,6 +19439,8 @@

parent = parent.domParent;
}

return true;
}

var uuid$1 = 0;
Expand Down Expand Up @@ -19674,7 +19678,7 @@

this.__computeMeasure(renderMode, ctx);
} // 非首次刷新如果没有更新则无需继续
else if (this.__checkUpdate(renderMode, ctx, width, height)) {
else if (!this.__checkUpdate(renderMode, ctx, width, height)) {
return;
} // 获取所有字体和大小测量,一般是同步,为了防止外部因素inject是异步写成了cb形式

Expand Down Expand Up @@ -19987,19 +19991,20 @@
var cacheHash = {};
var cacheList = [];
var updateRoot = this.__updateRoot;
var updateHash = this.__updateHash; // root更新特殊提前,因为有继承因素
var updateHash = this.__updateHash;
var hasUpdate; // root更新特殊提前,因为有继承因素

if (updateRoot) {
this.__updateRoot = null;
parseUpdate(renderMode, this, updateHash, updateRoot, reflowList, measureList, cacheHash, cacheList); // 此时做root检查,防止root出现继承等无效样式
hasUpdate || (hasUpdate = parseUpdate(renderMode, this, updateHash, updateRoot, reflowList, measureList, cacheHash, cacheList)); // 此时做root检查,防止root出现继承等无效样式

this.__checkRoot(width, height);
} // 汇总处理每个节点


var keys = Object.keys(updateHash);
keys.forEach(function (k) {
parseUpdate(renderMode, _this5, updateHash, updateHash[k], reflowList, measureList, cacheHash, cacheList);
hasUpdate || (hasUpdate = parseUpdate(renderMode, _this5, updateHash, updateHash[k], reflowList, measureList, cacheHash, cacheList));
}); // 先做一部分reset避免下面measureList干扰

this.__reflowList = reflowList;
Expand Down Expand Up @@ -20077,6 +20082,7 @@
keys.forEach(function (k) {
delete updateHash[k].node.__uniqueUpdateId;
});
return hasUpdate;
}
/**
* 除首次外每次刷新前检查reflow列表,计算需要reflow的节点局部重新布局
Expand Down
2 changes: 1 addition & 1 deletion index.js.map

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions src/animate/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,25 +676,27 @@ function binarySearch(i, j, time, frames) {

function getEasing(ea) {
let timingFunction;
if(/^\s*(?:cubic-bezier\s*)?\(\s*[\d.]+\s*,\s*[-\d.]+\s*,\s*[\d.]+\s*,\s*[-\d.]+\s*\)\s*$/i.test(ea)) {
let v = ea.match(/[\d.]+/g);
timingFunction = easing.cubicBezier(v[0], v[1], v[2], v[3]);
}
else if((timingFunction = /^\s*steps\s*\(\s*(\d+)(?:\s*,\s*(\w+))?\s*\)/i.exec(ea))) {
let steps = parseInt(timingFunction[1]);
let stepsD = timingFunction[2];
timingFunction = function(percent) {
// steps有效定义正整数
if(steps && steps > 0) {
let per = 1 / steps;
let n = stepsD === 'start' ? Math.ceil(percent / per) : Math.floor(percent / per);
return n / steps;
}
return percent;
};
}
else {
timingFunction = easing[ea] || linear;
if(ea) {
if(/^\s*(?:cubic-bezier\s*)?\(\s*[\d.]+\s*,\s*[-\d.]+\s*,\s*[\d.]+\s*,\s*[-\d.]+\s*\)\s*$/i.test(ea)) {
let v = ea.match(/[\d.]+/g);
timingFunction = easing.cubicBezier(v[0], v[1], v[2], v[3]);
}
else if((timingFunction = /^\s*steps\s*\(\s*(\d+)(?:\s*,\s*(\w+))?\s*\)/i.exec(ea))) {
let steps = parseInt(timingFunction[1]);
let stepsD = timingFunction[2];
timingFunction = function(percent) {
// steps有效定义正整数
if(steps && steps > 0) {
let per = 1 / steps;
let n = stepsD === 'start' ? Math.ceil(percent / per) : Math.floor(percent / per);
return n / steps;
}
return percent;
};
}
else {
timingFunction = easing[ea];
}
}
return timingFunction;
}
Expand All @@ -710,7 +712,7 @@ function getEasing(ea) {
function calIntermediateStyle(frame, percent, target) {
let style = clone(frame.style);
let timingFunction = getEasing(frame.easing);
if(timingFunction !== linear) {
if(timingFunction && timingFunction !== linear) {
percent = timingFunction(percent);
}
let transition = frame.transition;
Expand Down
9 changes: 6 additions & 3 deletions src/node/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function parseUpdate(renderMode, root, updateHash, target, reflowList, measureLi
}
parent = parent.domParent;
}
return true;
}

let uuid = 0;
Expand Down Expand Up @@ -444,7 +445,7 @@ class Root extends Dom {
this.__computeMeasure(renderMode, ctx);
}
// 非首次刷新如果没有更新则无需继续
else if(this.__checkUpdate(renderMode, ctx, width, height)) {
else if(!this.__checkUpdate(renderMode, ctx, width, height)) {
return;
}
// 获取所有字体和大小测量,一般是同步,为了防止外部因素inject是异步写成了cb形式
Expand Down Expand Up @@ -698,17 +699,18 @@ class Root extends Dom {
let cacheList = [];
let updateRoot = this.__updateRoot;
let updateHash = this.__updateHash;
let hasUpdate;
// root更新特殊提前,因为有继承因素
if(updateRoot) {
this.__updateRoot = null;
parseUpdate(renderMode, this, updateHash, updateRoot, reflowList, measureList, cacheHash, cacheList);
hasUpdate ||= parseUpdate(renderMode, this, updateHash, updateRoot, reflowList, measureList, cacheHash, cacheList);
// 此时做root检查,防止root出现继承等无效样式
this.__checkRoot(width, height);
}
// 汇总处理每个节点
let keys = Object.keys(updateHash);
keys.forEach(k => {
parseUpdate(renderMode, this, updateHash, updateHash[k], reflowList, measureList, cacheHash, cacheList);
hasUpdate ||= parseUpdate(renderMode, this, updateHash, updateHash[k], reflowList, measureList, cacheHash, cacheList);
});
// 先做一部分reset避免下面measureList干扰
this.__reflowList = reflowList;
Expand Down Expand Up @@ -772,6 +774,7 @@ class Root extends Dom {
keys.forEach(k => {
delete updateHash[k].node.__uniqueUpdateId;
});
return hasUpdate;
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/style/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,6 @@ function computeMeasure(node, isHost) {
let parentComputedStyle = !isHost && parent.computedStyle;
change.MEASURE_KEY_SET.forEach(k => {
let v = currentStyle[k];
// console.log(node.tagName, k, v);
if(v.unit === INHERIT) {
computedStyle[k] = isHost ? reset.INHERIT[k] : parentComputedStyle[k];
}
Expand Down

0 comments on commit 4bae6ca

Please sign in to comment.