Skip to content

Commit

Permalink
private
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed Sep 5, 2024
1 parent f6700b0 commit d174c3d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions addon/components/dragula.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ export const events = {
};

export default class Dragula extends Component {
drake;
#drake;

constructor() {
super(...arguments);

this.drake = dragula({ ...this.args.options });
this.#drake = dragula({ ...this.args.options });
this._setupHandlers();
this.args.onReady?.(this.drake);
this.args.onReady?.(this.#drake);
}

@action
addContainer(element) {
this.drake.containers.push(element);
this.#drake.containers.push(element);
}

@action
removeContainer(element) {
this.drake.containers.splice(this.drake.containers.indexOf(element), 1);
this.#drake.containers.splice(this.#drake.containers.indexOf(element), 1);
}

willDestroy() {
super.willDestroy(...arguments);
this.drake.destroy();
this.#drake.destroy();
}

_setupHandlers() {
keys(events).forEach((name) => {
const handler = this.args[events[name]];

if (typeof handler === 'function') {
this.drake.on(name, handler);
this.#drake.on(name, handler);
}
});
}
Expand Down

0 comments on commit d174c3d

Please sign in to comment.