0
안녕하세요 저는 Greensock의 draggable 스냅 속성을 throwprops 또는 livesnap 없이도 사용할 수있는 방법을 찾으려고합니다. 가장 가까운 지점에 맞추기 위해 '.face'를 놓아두면 좋겠다. 그것은 livesnap와 함께 작동하지만 나는 그것의 들쭉날쭉 한 드래그 싶지 않아요. 여기 Greensock - Throwprops없이 그리드에 붙임
내가 지금 함께 일하고 있어요 무엇 :var droppables = $('.face');
var choice = $('.choice');
var gridWidth = 192;
var gridHeight = 256;
var overlapThreshold = '50%';
function onDrop(dragged, dropped) {
TweenMax.fromTo(dropped, 0.2, {opacity:1}, {opacity:0.5, repeat:1, yoyo:true});
}
Draggable.create(droppables, {
type:'x,y',
bounds:$('.content'),
liveSnap:true,
snap: {
x: function(endValue) {
return Math.round(endValue/gridWidth) * gridWidth;
},
y: function(endValue) {
return Math.round(endValue/gridHeight) * gridHeight;
}
},
onDrag: function(e) {
var i = droppables.length;
while (--i > -1) {
if (this.hitTest(choice[i], overlapThreshold)) {
$(droppables[i]).addClass('highlight');
} else {
$(droppables[i]).removeClass('highlight');
}
}
},
onDragEnd:function(e) {
var i = droppables.length;
while (--i > -1) {
if (this.hitTest(choice[i], overlapThreshold)) {
onDrop(this.target, choice[i]);
}
}
어떤 도움도 좋은 것입니다.