From d7ed23c6404e61d1f96279cf4226d7513c2cb330 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 9 Jun 2021 20:45:13 +0200 Subject: [PATCH] Add Frames class --- src/canvas/model/Frames.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/canvas/model/Frames.js b/src/canvas/model/Frames.js index 380116616..17e313d20 100644 --- a/src/canvas/model/Frames.js +++ b/src/canvas/model/Frames.js @@ -2,24 +2,22 @@ import { bindAll } from 'underscore'; import { Collection } from 'backbone'; import model from './Frame'; -export default Collection.extend({ - model, - +export default class Frames extends Collection { initialize(models, config = {}) { bindAll(this, 'itemLoaded'); this.config = config; this.on('reset', this.onReset); this.on('remove', this.onRemove); - }, + } onReset(m, opts = {}) { const prev = opts.previousModels || []; prev.map(p => this.onRemove(p)); - }, + } onRemove(removed) { removed && removed.onRemove(); - }, + } itemLoaded() { this.loadedItems++; @@ -28,20 +26,22 @@ export default Collection.extend({ this.trigger('loaded:all'); this.listenToLoadItems(0); } - }, + } listenToLoad() { this.loadedItems = 0; this.itemsToLoad = this.length; this.listenToLoadItems(1); - }, + } listenToLoadItems(on) { this.forEach(item => item[on ? 'on' : 'off']('loaded', this.itemLoaded)); - }, + } add(m, o = {}) { const { config } = this; return Collection.prototype.add.call(this, m, { ...o, config }); } -}); +} + +Frames.prototype.model = model;