Skip to content

Commit 4a7a163

Browse files
author
SeungpilPark
committed
#5 Working with loading progress status
1 parent 1e28023 commit 4a7a163

5 files changed

Lines changed: 46 additions & 4 deletions

File tree

src/main/webapp/examples/develope.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@
321321
// Shape 이 Disconnect 되었을 때의 이벤트 리스너
322322
canvas.onDisconnectShape(function (event, edgeElement, fromElement, toElement) {
323323
});
324+
325+
canvas.onLoading(function(event, progress){
326+
console.log(progress);
327+
});
324328
// window.canvas = canvas;
325329
//
326330
// var worker = new Worker('../src/worker/og-worker.js');

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT-All.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/opengraph/OpenGraph-0.1.2-SNAPSHOT.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33011,7 +33011,7 @@ OG.graph.Canvas.prototype = {
3301133011
});
3301233012
sliderBar.css({
3301333013
position: 'relative',
33014-
'writing-mode': 'bt-lr', /* IE */
33014+
//'writing-mode': 'bt-lr', /* IE */
3301533015
'width': '100%',
3301633016
'height': '8px'
3301733017
});
@@ -34423,6 +34423,8 @@ OG.graph.Canvas.prototype = {
3442334423
fromEdge, toEdge, label, fromLabel, toLabel, angle, value, data, dataExt, element, loopType, taskType, swimlane, textList;
3442434424

3442534425
this._RENDERER.clear();
34426+
var renderer = this._RENDERER;
34427+
$(renderer._PAPER.canvas).trigger('loading', ['start']);
3442634428

3442734429
if (json && json.opengraph && json.opengraph.cell && OG.Util.isArray(json.opengraph.cell)) {
3442834430
canvasWidth = json.opengraph['@width'];
@@ -34447,6 +34449,9 @@ OG.graph.Canvas.prototype = {
3444734449
}
3444834450

3444934451
cell = json.opengraph.cell;
34452+
var totalCount = cell.length;
34453+
var cellCount = 0;
34454+
3445034455
for (var i = 0, leni = cell.length; i < leni; i++) {
3445134456
id = cell[i]['@id'];
3445234457
parent = cell[i]['@parent'];
@@ -34595,9 +34600,13 @@ OG.graph.Canvas.prototype = {
3459534600
if (dataExt) {
3459634601
element.dataExt = OG.JSON.decode(unescape(dataExt));
3459734602
}
34603+
34604+
cellCount++;
34605+
$(renderer._PAPER.canvas).trigger('loading', [Math.round((cellCount/totalCount)*100)]);
3459834606
}
3459934607

3460034608
this.fastLoadingOFF();
34609+
$(renderer._PAPER.canvas).trigger('loading', ['end']);
3460134610

3460234611
return {
3460334612
width: maxX - minX,
@@ -34610,6 +34619,7 @@ OG.graph.Canvas.prototype = {
3461034619
}
3461134620

3461234621
this.fastLoadingOFF();
34622+
$(renderer._PAPER.canvas).trigger('loading', ['end']);
3461334623

3461434624
return {
3461534625
width: 0,
@@ -34947,6 +34957,15 @@ OG.graph.Canvas.prototype = {
3494734957
$(this.getRootElement()).bind('expanded', function (event, element) {
3494834958
callbackFunc(event, element);
3494934959
});
34960+
},
34961+
34962+
/**
34963+
* 캔버스 로딩 이벤트 리스너
34964+
*/
34965+
onLoading: function(callbackFunc){
34966+
$(this.getRootElement()).bind('loading', function (event, progress) {
34967+
callbackFunc(event, progress);
34968+
});
3495034969
}
3495134970
}
3495234971
;

src/main/webapp/src/graph/Canvas.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ OG.graph.Canvas.prototype = {
972972
});
973973
sliderBar.css({
974974
position: 'relative',
975-
'writing-mode': 'bt-lr', /* IE */
975+
//'writing-mode': 'bt-lr', /* IE */
976976
'width': '100%',
977977
'height': '8px'
978978
});
@@ -2384,6 +2384,8 @@ OG.graph.Canvas.prototype = {
23842384
fromEdge, toEdge, label, fromLabel, toLabel, angle, value, data, dataExt, element, loopType, taskType, swimlane, textList;
23852385

23862386
this._RENDERER.clear();
2387+
var renderer = this._RENDERER;
2388+
$(renderer._PAPER.canvas).trigger('loading', ['start']);
23872389

23882390
if (json && json.opengraph && json.opengraph.cell && OG.Util.isArray(json.opengraph.cell)) {
23892391
canvasWidth = json.opengraph['@width'];
@@ -2408,6 +2410,9 @@ OG.graph.Canvas.prototype = {
24082410
}
24092411

24102412
cell = json.opengraph.cell;
2413+
var totalCount = cell.length;
2414+
var cellCount = 0;
2415+
24112416
for (var i = 0, leni = cell.length; i < leni; i++) {
24122417
id = cell[i]['@id'];
24132418
parent = cell[i]['@parent'];
@@ -2556,9 +2561,13 @@ OG.graph.Canvas.prototype = {
25562561
if (dataExt) {
25572562
element.dataExt = OG.JSON.decode(unescape(dataExt));
25582563
}
2564+
2565+
cellCount++;
2566+
$(renderer._PAPER.canvas).trigger('loading', [Math.round((cellCount/totalCount)*100)]);
25592567
}
25602568

25612569
this.fastLoadingOFF();
2570+
$(renderer._PAPER.canvas).trigger('loading', ['end']);
25622571

25632572
return {
25642573
width: maxX - minX,
@@ -2571,6 +2580,7 @@ OG.graph.Canvas.prototype = {
25712580
}
25722581

25732582
this.fastLoadingOFF();
2583+
$(renderer._PAPER.canvas).trigger('loading', ['end']);
25742584

25752585
return {
25762586
width: 0,
@@ -2908,6 +2918,15 @@ OG.graph.Canvas.prototype = {
29082918
$(this.getRootElement()).bind('expanded', function (event, element) {
29092919
callbackFunc(event, element);
29102920
});
2921+
},
2922+
2923+
/**
2924+
* 캔버스 로딩 이벤트 리스너
2925+
*/
2926+
onLoading: function(callbackFunc){
2927+
$(this.getRootElement()).bind('loading', function (event, progress) {
2928+
callbackFunc(event, progress);
2929+
});
29112930
}
29122931
}
29132932
;

0 commit comments

Comments
 (0)