Skip to content

Commit

Permalink
Publishing load-progress events. Relates to #185.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Nov 19, 2015
1 parent 09e97aa commit 66c4e33
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ dwv.App = function ()
*/
function onLoadProgress(event)
{
fireEvent(event);
if( event.lengthComputable )
{
var percent = Math.round((event.loaded / event.total) * 100);
Expand Down
3 changes: 2 additions & 1 deletion src/io/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ dwv.io.File.createProgressHandler = function (n, calculator, baseHandler) {
if( event.lengthComputable )
{
var percent = Math.round((event.loaded / event.total) * 100);
var ev = {lengthComputable: true, loaded: calculator(n, percent), total: 100};
var ev = {type: "load-progress", lengthComputable: true,
loaded: calculator(n, percent), total: 100};
baseHandler(ev);
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/io/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ dwv.io.Url.createProgressHandler = function (n, calculator, baseHandler) {
if( event.lengthComputable )
{
var percent = Math.round((event.loaded / event.total) * 100);
var ev = {lengthComputable: true, loaded: calculator(n, percent), total: 100};
var ev = {type: "load-progress", lengthComputable: true,
loaded: calculator(n, percent), total: 100};
baseHandler(ev);
}
};
Expand Down
1 change: 1 addition & 0 deletions viewers/mobile/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $(document).ready( function()
// example app listening
//var listener = function (event) { console.log("event: "+event.type); };
//myapp.addEventListener("load-end", listener);
//myapp.addEventListener("load-progress", listener);
//myapp.addEventListener("draw-create", listener);
//myapp.addEventListener("draw-move", listener);
//myapp.addEventListener("draw-change", listener);
Expand Down

0 comments on commit 66c4e33

Please sign in to comment.