make fewer requests for item stats when scrolling fast through a list

This commit is contained in:
rolux 2010-07-16 09:12:46 +02:00
parent 4a990aea9b
commit fbd3dee4d3

View file

@ -656,7 +656,7 @@ $ui.statusbar = new Ox.Bar({
element: $ui.rightPanel = new Ox.SplitPanel({ element: $ui.rightPanel = new Ox.SplitPanel({
elements: [ elements: [
{ {
element: $ui.toolbar, element: $ui.toolbar.css({ zIndex: 2 }), // fixme: remove later
size: 24 size: 24
}, },
{ {
@ -893,97 +893,100 @@ $ui.statusbar = new Ox.Bar({
Ox.Event.bind("select_list", function(event, data) { Ox.Event.bind("select_list", function(event, data) {
var $still, $timeline; var $still, $timeline;
ui.selectedMovies = data.ids; ui.selectedMovies = data.ids;
if (data.ids.length) { setTimeout(function() {
$ui.mainMenu.enableItem("copy"); if (
$ui.mainMenu.enableItem("openmovie"); data.ids.length == ui.selectedMovies.length &&
} else { (data.ids.length == 0 || data.ids[0] == ui.selectedMovies[0])
$ui.mainMenu.disableItem("copy"); ) {
$ui.mainMenu.disableItem("openmovie"); if (data.ids.length) {
} $ui.mainMenu.enableItem("copy");
if (data.ids.length == 1) { $ui.mainMenu.enableItem("openmovie");
setTimeout(function() { } else {
if (data.ids[0] != ui.selectedMovies[0]) { $ui.mainMenu.disableItem("copy");
Ox.print("cancel after timeout...") $ui.mainMenu.disableItem("openmovie");
return;
} }
$still = $("<img>") if (data.ids.length == 1) {
.attr({ $still = $("<img>")
src: "http://0xdb.org/" + data.ids[0] + "/still.jpg" .attr({
}) src: "http://0xdb.org/" + data.ids[0] + "/still.jpg"
.one("load", function() { })
if (data.ids[0] != ui.selectedMovies[0]) { .one("load", function() {
Ox.print("cancel after load...") if (data.ids[0] != ui.selectedMovies[0]) {
return; Ox.print("cancel after load...")
} return;
var image = $still[0], }
imageWidth = image.width, var image = $still[0],
imageHeight = image.height, imageWidth = image.width,
width = $ui.info.width(), imageHeight = image.height,
height = imageHeight * width / imageWidth; width = $ui.info.width(),
ui.infoRatio = width / height; height = imageHeight * width / imageWidth;
$still.css({ ui.infoRatio = width / height;
position: "absolute", $still.css({
left: 0, position: "absolute",
top: 0, left: 0,
//width: width + "px", top: 0,
//height: height + "px", //width: width + "px",
width: "100%", //height: height + "px",
width: "100%",
opacity: 0
})
.appendTo($ui.info.$element)
.animate({
opacity: 1
});
$ui.infoStill.animate({
opacity: 0 opacity: 0
}) }, 250);
.appendTo($ui.info.$element) $ui.info.animate({
.animate({ height: (height + 16) + "px"
opacity: 1 }, 250, function() {
$ui.infoStill.remove();
$ui.infoStill = $still;
}); });
$ui.infoStill.animate({
opacity: 0
}, 250);
$ui.info.animate({
height: (height + 16) + "px"
}, 250, function() {
$ui.infoStill.remove();
$ui.infoStill = $still;
}); });
}); /*
/* $timeline = $("<img>")
$timeline = $("<img>") .attr({
.attr({ src: "http://0xdb.org/" + data.ids[0] + "/timeline/timeline.png"
src: "http://0xdb.org/" + data.ids[0] + "/timeline/timeline.png" })
}) .one("load", function() {
.one("load", function() { $timeline.css({
$timeline.css({ position: "absolute",
position: "absolute", left: 0,
left: 0, bottom: "16px",
bottom: "16px", opacity: 0
})
.appendTo($ui.info.$element)
.animate({
opacity: 1
});
$ui.infoTimeline.animate({
opacity: 0 opacity: 0
}) }, 250, function() {
.appendTo($ui.info.$element) $ui.infoTimeline.remove();
.animate({ $ui.infoTimeline = $timeline;
opacity: 1
}); });
$ui.infoTimeline.animate({
opacity: 0
}, 250, function() {
$ui.infoTimeline.remove();
$ui.infoTimeline = $timeline;
}); });
}); */
*/ }
}, 100); app.request("find", {
} query: {
app.request("find", { conditions: $.map(data.ids, function(id, i) {
query: { return {
conditions: $.map(data.ids, function(id, i) { key: "id",
return { value: id,
key: "id", operator: "="
value: id, }
operator: "=" }),
operator: "|"
} }
}), }, function(result) {
operator: "|" $ui.selected.html(constructStatus("selected", result.data));
});
} else {
Ox.print("cancelled after timeout");
} }
}, function(result) { }, 100);
$ui.selected.html(constructStatus("selected", result.data));
});
}); });
// Resize // Resize