Merci pour ta réaction..
je me permet de mettre a jour mon post car je n'ai plus le souci precedent
malgrer cela j'ai au moment de cliqué sur l'element de la liste l'erreur en dessous:
- je charge ma liste comme précedement
- je clique sur un element
- je charge normalement la description avec une image
- et j'ai l'erreur suivante:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
core.umd.js:3467 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ core.umd.js:3467
next @ core.umd.js:6924
t.object.i @ core.umd.js:6172
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.umd.js:6164
onError @ core.umd.js:6388
onHandleError @ core.umd.js:6263
ZoneDelegate.handleError @ zone.js:236
Zone.runTask @ zone.js:157
ZoneTask.invoke @ zone.js:335
r.args.(anonymous function) @ zone.js:970
core.umd.js:3468 TypeError: Cannot read property 'getContext' of null
at http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:174:19747
at ZoneDelegate.invokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:7165)
at Object.onInvokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:76:12632)
at ZoneDelegate.invokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:7101)
at Zone.runTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:4405)
at ZoneTask.invoke (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:8329)
at r.args.(anonymous function) (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:209:105)
ErrorHandler.handleError @ core.umd.js:3468
next @ core.umd.js:6924
t.object.i @ core.umd.js:6172
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.umd.js:6164
onError @ core.umd.js:6388
onHandleError @ core.umd.js:6263
ZoneDelegate.handleError @ zone.js:236
Zone.runTask @ zone.js:157
ZoneTask.invoke @ zone.js:335
r.args.(anonymous function) @ zone.js:970
viewer.component.ts:137 Uncaught TypeError: Cannot read property 'getContext' of null
at http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:174:19747
at ZoneDelegate.invokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:7165)
at Object.onInvokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:76:12632)
at ZoneDelegate.invokeTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:7101)
at Zone.runTask (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:4405)
at ZoneTask.invoke (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:230:8329)
at r.args.(anonymous function) (http://localhost:8000/proj/v0.8.8/dist/vendor.bundle.js:209:105) |
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
j'ai cette erreur quand je recharge la page et que ensuite je selectionne un element..
l'erreur ne se reproduit plus quand je continue..
Une idée?
EDIT: en fait il ne trouve pas un element dans mon DOM quand je vais le checher:
var canvas: any = document.getElementById(name + "Canvas")
quand je recharge la page le panneau description n'est pas charger ce qui est normale..
car je veux l'afficher seulement au click sur l'element de ma liste.
le DOM mes du temps a charger c'est normale?
peut être l'utilisation du websocket est lent..
non, je ne pense pas,
mais alors pourquoi le dom de ma description met du temp a se charger?
voici le code, je met un time out de 1 sec et je n'est plus cette erreur:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
setTimeout(() => {
var canvas: any = document.getElementById(name + "Canvas");
$(canvas).attr('width', img.width + 'px');
$(canvas).attr('height', img.height + 'px');
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
if (name == 'typeOne') {
this.typeOneDataUrl = canvas.toDataURL();
} else {
this.typeTwoDataUrl = canvas.toDataURL();
}
if (this.timeOutViewerOption) clearTimeout(this.timeOutViewerOption);
this.timeOutViewerOption = setTimeout(() => {
this.adaptViewerOptionSize();
});
},1000); |
Partager