マルチページ環境でFabricJSを使用しています。私たちのページリストビューは、キャンバス上で何かが変更された場合に生成されるサムネイルを使用する必要があります。今我々はいくつかのオブジェクト関連のイベントに耳を傾け、このような変化にサムネイルを更新している:ファブリックJS - ページのサムネイルを動的に変更
canvas.on('object:modified', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:moving', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:over', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:out', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:removed', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:rotating', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('object:scaling', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
canvas.on('path:created', function (option) {
PagesControllerScope && PagesControllerScope.refreshSavePage();
});
をため可能なすべての変更を定義することなく、「一般的な」方法でこのような何かをachiveする方法はありますそれぞれのオブジェクトまたはキャンバス自体?
基本的には、キャンバス上で何かが変更されたり、itsef(サイズ、背景など)が変更されるたびに、「refreshSavePage()」関数が呼び出されます。
私は「After:render」を使用したいと考えていましたが、これは何度も実行されるため、これはオプションではありません。それはどんなsomething is changed
イベントはありません、単一のタイム親指
clearInterval(drawThumb);
drawThumb = setTimeout(function() {
// code for generate thumb
clearInterval(drawThumb);
}, 2000);
マウスアップ後に '移動/オーバー/アウト/回転/スケーリング'の間に保存する必要はありません。 'オブジェクト:変更されました'が起動するので、その時間だけを保存します。 – Durga
Durgaに感謝します。私は「テキスト:変更」、「テキスト:選択:変更」、「オブジェクト:変更」などを使用するだけではないと思います。しかし、キャンバスのサイズやバックグラウンドを変更する方法はどうですか。または、オブジェクトを前面に送る。何か案が? –
私は、あなたの関数内では、背景を変更またはサイズ変更する場所でのみ呼び出すことができると思います。そのためのイベントはありません。 – Durga