-2

Hi Im still new to meteor, I want to implement this npm called swing. My questions are:

  • This can be just installed as an npm module in meteor and use all of its features?
  • How is the event hangling? can I use meteor's event handler on templates?

If any of you can provide some example of how to implement this great nmp in meteor would be great

svelandiag
  • 4,231
  • 1
  • 36
  • 72

1 Answers1

1

I hope these will answer your two points:

  1. No need for npm. This is a library for the browser. Unless you're using tools like browserify, npm packages are mainly server side packages. Grab this https://github.com/gajus/swing/blob/master/dist/swing.min.js and place it inside your Meteor project under client/compatibility as that's where you should place any external libraries.

From there you are safe to use the library (inside the Template.tinder.onRendered() of course):

stack.on('throwout', function (e) {
    console.log('Card has been thrown out of the stack.');
    console.log('Throw direction: ' + (e.throwDirection == Card.DIRECTION_LEFT ? 'left' : 'right'));
});
  1. You can't really rely on the events from jQuery in this case as your library has different hooks, so event handling will be made as explained above.

JSYK, the code below will not do anything in Meteor (even throw an Error), I recommend you follow their github README for all events, hooks and callback names.

Template.tinder.events({
  'throwout .card li': function(e) {
  }
});
Radu Chiriac
  • 1,374
  • 3
  • 18
  • 34