javascript - Interactjs decreases data-y attribute of an element to 0 in Safari -
i using interactjs angular js. use plugin dragging in y-axis , grid in in 1 container. works fine in chrome , firefox. however, when move grid in safari, data-y gets decreased 0 @ end. code:
.draggable({ // enable inertial throwing enabled:true, inertia: true, snap: { targets: [ interact.createsnapgrid({ x: 0, y: 30}) ], range: infinity, relativepoints: [ { x: 0, y: 0 } ] }, // keep element within area of it"s parent restrict: { restriction: "parent", endonly: true, elementrect: { top: 0, left: 0, bottom: 1, right: 1 } }, // enable autoscroll autoscroll: true, // call function on every dragmove event onmove: function(event){ console.log("onmove"); var target = event.target, x = parsefloat(target.getattribute("data-x")) + event.dx, y = parsefloat(target.getattribute("data-y")) + event.dy; // translate element target.style.webkittransform = target.style.transform = "translate(" + 0 + "px, " + y + "px)"; console.log("y onmove: "+y); // update posiion attributes target.setattribute("data-x", 0); target.setattribute("data-y", y); }, onend: function(event){ console.log("onend"); var target = event.target, y = parsefloat(target.getattribute("data-y")); console.log("y onend: "+ y); y = getmovegrid(y); // translate element target.style.webkittransform = target.style.transform = "translate(" + 0 + "px, " + y + "px)"; // update posiion attributes target.setattribute("data-x", 0); target.setattribute("data-y", y); $scope.updatereservation(event.target.getattribute("id")); } }) .on("dragmove", function (event) { console.log("dragmove"); var x = 0+ event.dx; var y = 0 +event.dy; event.target.style.webkittransform = event.target.style.transform = "translate(" + x + "px, " + y + "px)"; })
the log in console when dragged grid (in safari):
[log] dragmove (reservations.js, line 378) [log] onmove (reservations.js, line 346) [log] y onmove: 45 (reservations.js, line 354) //then several y onmove: 15 [log] dragmove (reservations.js, line 378) [log] onmove (reservations.js, line 346) [log] y onmove: 15 (reservations.js, line 354) //then 1 y onmove: 0 , onend function run [log] dragmove (reservations.js, line 378) [log] onmove (reservations.js, line 346) [log] y onmove: 0 (reservations.js, line 354) [log] onend (reservations.js, line 362) [log] y onend: 0 (reservations.js, line 365)
in chrome print
reservations.js:346 onmove reservations.js:354 y onmove: 45 reservations.js:355 reservations.js:362 onend reservations.js:365 y onend: 45
Comments
Post a Comment