Commit 587b48f2 authored by Xiaowu Zhang's avatar Xiaowu Zhang

change use of requestAnimationFrame

parent 8bce8679
......@@ -72,7 +72,7 @@
})
.allowPublicAcquisition("plGive", function (param_list) {
if (this.save === undefined) {
return 0;
return this.save;
}
return this.save[param_list[0]];
})
......@@ -88,6 +88,12 @@
return jio_gadget.post.apply(jio_gadget, param_list);
});
})
.allowPublicAcquisition("invalideJioSave", function (param_list) {
return this.getDeclaredGadget(storageType(this.storageType))
.push(function (jio_gadget) {
return jio_gadget.invalideJioSave.apply(jio_gadget, param_list);
});
})
.allowPublicAcquisition("jio_putAttachment", function (param_list) {
return this.getDeclaredGadget(storageType(this.storageType))
.push(function (jio_gadget) {
......
......@@ -13,6 +13,9 @@
.declareMethod('createJio', function (jio_options) {
this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options);
})
.declareMethod('invalideJioSave', function (jio_options) {
this.save = {};
})
.declareMethod('allDocs', function () {
var storage = this.state_parameter_dict.jio_storage,
that = this;
......
......@@ -90,12 +90,28 @@
}
function promiseRequestAnimation(callback) {
var animationId;
var animationId,
callback_promise;
function canceller() {
window.cancelAnimationFrame(animationId);
if (callback_promise !== undefined) {
callback_promise.cancel();
}
}
//xxx
function resolver(resolve, reject) {
function tmp() {
callback_promise = new RSVP.Queue()
.push(function () {
callback();
animationId = window.requestAnimationFrame(tmp);
})
.push(undefined, function (error) {
canceller();
reject(error);
});
}
function resolver(resolve) {
animationId = window.requestAnimationFrame(callback);
animationId = window.requestAnimationFrame(tmp);
}
return new RSVP.Promise(resolver, canceller);
}
......@@ -122,9 +138,6 @@
gradient.addColorStop(0, '#f00');
that.audio.play();
drawFrame = function () {
if (that.audio.duration !== 0) {
bar_context.max = that.audio.duration;
}
array = getFFTValue(that);
canvasCtx.clearRect(0, 0, cwidth, cheight);
step = Math.round(array.length / meterNum);
......@@ -139,7 +152,6 @@
meterWidth,
cheight); //the meter
}
return promiseRequestAnimation(drawFrame);
};
return promiseRequestAnimation(drawFrame);
}
......@@ -161,13 +173,11 @@
return g.plGive("type");
})
.push(function (value) {
g.filter.type = value;
g.filter.type = value || 0;
return g.plGive("value");
})
.push(function (value) {
if (value === 0) {
value = 5000;
}
value = value || 5000;
g.filter.frequency.value = value;
})
.push(function () {
......@@ -222,6 +232,7 @@
return promiseEventListener(g.audio, "loadedmetadata", false);
})
.push(function () {
bar_context.max = g.audio.duration;
return g.plEnablePage();
})
.push(function () {
......
......@@ -10,6 +10,7 @@
.declareAcquiredMethod("displayThisTitle", "displayThisTitle")
.declareAcquiredMethod("plEnablePage", "plEnablePage")
.declareAcquiredMethod("plDisablePage", "plDisablePage")
.declareAcquiredMethod("invalideJioSave", "invalideJioSave")
.declareMethod("render", function () {
return this.displayThisTitle("upload");
})
......@@ -66,6 +67,9 @@
.push(function () {
return g.plDisablePage();
})
.push(function () {
return g.invalideJioSave();
})
.push(function () {
length = input_context.files.length;
for (i = 0; i < length; i += 1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment