سؤال

I read up on the draggable bounds and would like to set for the same size as the canvas (as the image goes out of site at the edge, is this possible?

هل كانت مفيدة؟

المحلول

var image = new Kinetic.Image({
    image : img,
    draggable: true,
  x : 100,
  y : 100,
  dragBoundFunc : function(pos) {
    if (pos.x < 0) {
      pos.x =0;
    }
    if (pos.y < 0) {
      pos.y =0;
    }
    if (pos.x > stage.width() - image.width()) {
      pos.x = stage.width() - image.width();
    }
    if (pos.y > stage.height() - image.height()) {
      pos.y = stage.height() - image.height();
    }
    return pos;
  }
});

DEMO

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top