javascript - How to set properties in an Ember component when using an event listener now that Ember.View is deprecated? -
my app using ember , interact js move elements around on screen. interact js uses event listener drag items around , sets top , left properties in ember component. works in ember 1.12, trying ready ember 2.0. ember.view.views[id]
how getting component ember.view no longer working. here component:
/* global interact*/ "use strict"; import ember "ember"; export default ember.component.extend({ top: 15, left: 15, // initiates interactjs allows element drug around on canvas // , restricts element movement canvas. interactjs: function () { var self = this, $self = self.$(); interact(".draggable").draggable({ inertia: false, autoscroll: true, restrict: { restriction: "parent", elementrect: { top: 0, left: 0, bottom: 0, right: 0 } }, onmove: self.dragmovelistener, }).resizable({ autoscroll: { container: "parent", margin: 50, distance: 5, interval: 10 } }); }.on("init"), // in event lose component cannot use this.set("top", y). dragmovelistener: function (event) { // how component var target = event.target, $comp = ember.$(target), compid = $comp.attr("id"), comp = ember.view.views[compid], // should use instead of ember.view? y, x; y = comp.get("top") + event.dy; x = comp.get("left") + event.dx; comp.set("top", y); comp.set("left", x); } });
how should getting component can set properties while in event? said in comment lose component in event, doing this.set("top", y)
in event not work. need component set property.
Comments
Post a Comment