vendor/assets/build/js/atome/atome.js in atome-0.4.5.4 vs vendor/assets/build/js/atome/atome.js in atome-0.4.7.0

- old
+ new

@@ -1,14 +1,18 @@ class AtomeDrag { constructor() { } - drag() { + drag(atome_drag_id) { // target elements with the "draggable" class - interact('.draggable') + self.current_obj = Opal.Utilities.$grab(atome_drag_id) + interact('.'+atome_drag_id) .draggable({ // enable inertial throwing + startAxis: 'x', + lockAxis: 'x', + // lockAxis: ''+lock_axis, inertia: true, // keep the element within the area of it's parent modifiers: [ interact.modifiers.restrictRect({ restriction: 'parent', @@ -23,14 +27,13 @@ move: dragMoveListener, start(event) { //TODO: optimise this passing the proc to the drag callback // lets get the current atome Object - self.current_obj = Opal.Utilities.$grab(event.target.id) + // self.current_obj = Opal.Utilities.$grab(atome_drag_id) // now get the grab proc - self.proc_meth = current_obj.$instance_variable_get("@html_drag") - // self.proc_meth = proc_found; + self.proc_meth = current_obj.bloc }, // call this function on every dragend event end(event) { } @@ -43,26 +46,37 @@ // keep the dragged position in the data-x/data-y attributes const x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx; const y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy // translate the element target.style.transform = 'translate(' + x + 'px, ' + y + 'px)' - // update the position attributes target.setAttribute('data-x', x) target.setAttribute('data-y', y) // CallBack here - Opal.Atome.$dragCallback(event.pageX, event.pageY,event.rect.left,event.rect.top,self.current_obj, self.proc_meth); - + self.current_obj.$dragCallback(event.pageX, event.pageY, event.rect.left, event.rect.top, self.current_obj, self.proc_meth); } } } // Usage: -let atomeDrag = new AtomeDrag(); -atomeDrag.drag(); +// let atomeDrag = new AtomeDrag(); +// atomeDrag.drag('atome_id', 'options'); -class Atomeanimation{ +class Atomeanimation { +} + +// TODO: put in a class + +const atome = { + jsSchedule: function (years, months, days, hours, minutes, seconds, proc) { + const now = new Date(); + const formatedDate = new Date(years, months - 1, days, hours, minutes, seconds); + const diffTime = Math.abs(formatedDate - now); + setTimeout(function () { + Opal.Object.$schedule_callback(proc); + }, diffTime); + } } \ No newline at end of file