mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
[ts] Use CSS transformX instead of left for performance.
This commit is contained in:
parent
40f192de43
commit
cf08ed3293
@ -67,10 +67,14 @@ var spineDemos = {
|
||||
$(".slider").each(function () {
|
||||
var div = $(this), handle = $("<div/>").appendTo(div);
|
||||
var bg = div.hasClass("before") ? $("<span/>").appendTo(div) : null;
|
||||
var hw = handle.width(), value = 0, object;
|
||||
var hw = handle.width(), value = 0, object, lastX;
|
||||
handle = handle[0];
|
||||
function positionHandle (percent) {
|
||||
var x = (div.width() - hw - 2) * percent;
|
||||
handle[0].style.left = x + "px";
|
||||
var x = Math.round((div.width() - hw - 2) * percent);
|
||||
if (x != lastX) {
|
||||
handle.style.transform = "translateX(" + x + "px)";
|
||||
lastX = x;
|
||||
}
|
||||
if (bg) bg.css("width", x + hw / 2);
|
||||
value = percent;
|
||||
}
|
||||
@ -93,8 +97,6 @@ var spineDemos = {
|
||||
set: positionHandle,
|
||||
get: function () { return value; }
|
||||
});
|
||||
div[0].handle = handle;
|
||||
div[0].positionHandle = positionHandle;
|
||||
});
|
||||
}
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user