Skip to content

Commit

Permalink
improve perf of visibility methods, imrpove gulp release task
Browse files Browse the repository at this point in the history
  • Loading branch information
chemerisuk committed Oct 24, 2014
1 parent 23a46bb commit 0dd43db
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
10 changes: 7 additions & 3 deletions gulpfile.js
Expand Up @@ -157,14 +157,18 @@ gulp.task("bump", function() {
.pipe(gulp.dest("./"));
});

gulp.task("release", ["bump", "compress"], function() {
gulp.task("release", ["bump", "compress"], function(done) {
var version = argv.tag;

if (!version) throw new gutil.PluginError("release", "You need to specify --tag parameter");

gulp.src(["./*.json", "./dist/*.js"])
.pipe(git.commit("version " + version))
.pipe(git.push())
.pipe(filter("package.json"))
.pipe(tag_version());
.pipe(tag_version())
.on("end", function() {
git.push("origin", "master", {}, function() {
git.push("origin", "master", {args: "--tags"}, done);
});
});
});
2 changes: 1 addition & 1 deletion src/element/matches.js
Expand Up @@ -19,7 +19,7 @@ _.register({

var checker = HOOK[selector] || SelectorMatcher(selector);

return !!checker(this[0], this);
return !!checker(this[0]);
}
}, () => {
return () => false;
Expand Down
2 changes: 1 addition & 1 deletion src/element/visibility.js
Expand Up @@ -56,7 +56,7 @@ var TRANSITION_EVENT_TYPE = WEBKIT_PREFIX ? "webkitTransitionEnd" : "transitione
eventType = animationName ? ANIMATION_EVENT_TYPE : TRANSITION_EVENT_TYPE;

if (typeof hiding !== "boolean") {
hiding = !HOOK[":hidden"](node);
hiding = !HOOK[":hidden"](node, computed);
}

if (animationHandler) {
Expand Down
21 changes: 11 additions & 10 deletions src/util/animationhandler.js
Expand Up @@ -9,7 +9,7 @@ var TRANSITION_PROPS = ["timing-function", "property", "duration", "delay"].map(
},
calcTransitionDuration = (transitionValues) => {
var delays = transitionValues[3],
durations = transitionValues[1];
durations = transitionValues[2];

return Math.max.apply(Math, durations.map((value, index) => {
return parseTimeValue(value) + (parseTimeValue(delays[index]) || 0);
Expand Down Expand Up @@ -41,7 +41,7 @@ export default (node, computed, animationName, hiding, done) => {
} else {
var transitionValues = TRANSITION_PROPS.map((prop, index) => {
// have to use regexp to split transition-timing-function value
return CSS.get[prop](computed).split(index === 2 ? /, (?!\d)/ : ", ");
return CSS.get[prop](computed).split(index ? ", " : /, (?!\d)/);
});

duration = calcTransitionDuration(transitionValues);
Expand All @@ -50,14 +50,15 @@ export default (node, computed, animationName, hiding, done) => {

if (transitionValues[1].indexOf("all") < 0) {
// try to find existing or use 0s length or make a new visibility transition
var visibilityTransitionIndex = transitionValues[1].indexOf("visibility");
if (visibilityTransitionIndex < 0) visibilityTransitionIndex = transitionValues[2].indexOf("0s");
if (visibilityTransitionIndex < 0) visibilityTransitionIndex = transitionValues[1].length;

transitionValues[0][visibilityTransitionIndex] = "linear";
transitionValues[1][visibilityTransitionIndex] = "visibility";
transitionValues[hiding ? 2 : 3][visibilityTransitionIndex] = "0s";
transitionValues[hiding ? 3 : 2][visibilityTransitionIndex] = duration + "ms";
var visibilityIndex = transitionValues[1].indexOf("visibility");

if (visibilityIndex < 0) visibilityIndex = transitionValues[2].indexOf("0s");
if (visibilityIndex < 0) visibilityIndex = transitionValues[1].length;

transitionValues[0][visibilityIndex] = "linear";
transitionValues[1][visibilityIndex] = "visibility";
transitionValues[hiding ? 2 : 3][visibilityIndex] = "0s";
transitionValues[hiding ? 3 : 2][visibilityIndex] = duration + "ms";
}

rules = transitionValues.map((props, index) => {
Expand Down
6 changes: 3 additions & 3 deletions src/util/selectorhooks.js
Expand Up @@ -5,14 +5,14 @@ var hooks = {};

hooks[":focus"] = (node) => node === DOCUMENT.activeElement;

hooks[":hidden"] = (node) => {
hooks[":hidden"] = (node, computed) => {
if (node.getAttribute("aria-hidden") === "true") return true;

var computed = _.computeStyle(node);
computed = computed || _.computeStyle(node);

return computed.visibility === "hidden" || computed.display === "none";
};

hooks[":visible"] = (node) => !hooks[":hidden"](node);
hooks[":visible"] = (node, computed) => !hooks[":hidden"](node, computed);

export default hooks;

0 comments on commit 0dd43db

Please sign in to comment.