How to use the card.dragged function in card

To help you get started, we’ve selected a few card examples, based on popular ways it is used in public projects.

github Yomguithereal / mtgnode / assets / js / src / playground / playground.module.drag.js View on Github external
// Retrieving position and sending to opponent
      var pos = {
        left: ui.position.left,
        top: ui.position.top,
        zIndex: $card.css('z-index'),
        id: $card.attr('number')
      };

      _this.dispatchRealtimeEvent('card.dragged', pos);
    };

    // Receptors
    //-----------

    // Reacting to a dragged card by op
    this.triggers.events['card.dragged'] = function(d, e) {
      var $card = $('#' + e.data.side + '_' + e.data.id);

      // Animating
      $card.css({
        left: e.data.left,
        top: _this.height - e.data.top - $card.height(),
        zIndex: e.data.zIndex
      });
    };
  }