Giter VIP home page Giter VIP logo

swing's People

Contributors

adelura avatar cllns avatar forkest avatar gajus avatar igorlesnenko avatar kkirsche avatar ksachdeva avatar nadangergeo avatar neozaru avatar peter-sharp avatar qnp avatar sparkomatic avatar ssanjun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swing's Issues

Hammer undefined when using require.js

Hello,

I am trying to use swing with require.js and I get the following error "Uncaught TypeError: undefined is not a function" for the line mc = new Hammer.Manager(targetElement, {...

Thank you for the greet plugin !

Reset stack - how?

Is there a method built in for reseting a stack of cards and having them thrown back into the pile?

If not, and I need to loop through each card and call card.throwIn(), how can I get the cards current X and Y, so they can animate from where they are currently on the page?

Swing example with full list of dependencies. Development version

Hello,

I found this plugin very neat and smooth working.
Only issue is that I can't figure out how to setup development version, so I could do modifications.

It works fine if I include swing-master/dist/swing.min.js, which is production version.

But I want to use files from src folder. I tried to include them all and kept getting errors, such as "require not defined" etc.

Could someone create an example, which would have all dependencies loaded from CDN in right order?

Thank you

Console.log in dist/swing.js

There is a console.log occuring whenever I begin throwing out a card.

This console.log is not in the src file so building will probably get rid of it.

EventObject should provide access to relevant Card object

Right now, EventObject has a member called target, which is the HTMLElement version of the card that corresponds to the event. It would be great if EventObject.target instead contained a Card object, or better yet: there could be a different member altogether, such as EventObject.card.

Either way, EventObject should provide access to the relevant Card object so that event handlers can better leverage the functionality of Card objects

Method for disabling swing/card

When the user clicks on a card, it zooms in to the card (with some css magic), showing more content, and is scrollable. The problem is that the user can't scroll because swing is still active on the card. Is there any easy way to disable swing with a method or "hack"?

I've tried listening to events and running event.preventDefault(), no luck.

How to handle card?

I have 2 questions, please teach me. Thank you and sorry my bad English.

Q1: How to handle card? Example: Tinder have Like or Unlike, i want when i click Like Card will animate left to right.
Q2: I want when card throught 50% it will drop

Please teach me, i want an example like Tinder. Thank so much!

Debug output

There is annoying debug output on line 3994 (in the distributed version) in version 1.1.3. As far as I can tell it already got fixed in the sources (by this commit ce8dc33) but it is still unfixed in the release/swing.js file.

Could you please release a new version 1.1.4 which contains this fix?
Thanks in advance!

Changing card.throwOut speed

Is it possible to change the speed of card.throwOut? For example, if I do a drag with my finger, the speed is natural. However, if I issue a card.throwOut(-1,0) or similar, the card flashes by so quick you almost don't notice.

How to throwout last card on stack

Hi there,

I'm trying to figure out how to use the stack.getCard method. What I want to do is get a specific card using a li html attribute. I need this because I want to throw out the card that is on top of the stack. (Just like Tinder, which has dislike and like button)

How can I select the card that is last in the stack and then throw that one out?

I realise that this is probably quite simple, but I'm not very experienced with JavaScript and I'd love to get this awesome plugin to work.

Thanks in advance for helping me out!

Unresponsive on Android

On Android this script is very unresponsive. When you try to move a card around nothing happens until you remove your finger and try to move it again. And then it still is very laggy.

I tested it on Motorola Moto G 2. Generation with Android 5.x and Android 6.0.

Use ESHint

Remove "jshint" dev dependency from package.json and the gulp task.

sh:

npm install gulp-eslint --save-dev

gulpfile.js:

var eslint = require('gulp-eslint');

gulp.task('lint', function () {
    return gulp
        .src(['./src/*.js', './src/cinemas/*/*.js', './tests/*.js'])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failOnError());
});

.eslintrc:

{
    "rules": {
        "no-console": 0,
        "no-extra-parens": 2,
        "no-reserved-keys": 2,
        "no-eq-null": 2,
        "no-extend-native": 2,
        "no-process-env": 2,
        "no-self-compare": 2,
        "no-void": 2,
        "no-warning-comments": [1, { "terms": ["todo", "@toto"], "location": "start" }],
        "vars-on-top": 2,
        "wrap-iife": [2, "inside"],
        "global-strict": [2, "always"],
        "new-cap": 0,
        "no-shadow": 0,
        "no-mixed-requires": 0,
        "no-new-require": 2,
        "brace-style": [2, "1tbs"],
        "comma-style": [2, "last"],
        "func-style": [2, "expression"],
        "no-inline-comments": 2,
        "no-lonely-if": 2,
        "no-multiple-empty-lines": 2,
        "no-nested-ternary": 2,
        "one-var": 2,
        "operator-assignment": [2, "always"],
        "padded-blocks": [2, "never"],
        "quote-props": [2, "as-needed"],
        "quotes": [2, "single"],
        "space-after-keywords": [2, "always"],
        "space-before-blocks": [2, "always"],
        "space-in-brackets": [2, "never"],
        "space-in-parens": [2, "never"],
        "space-unary-ops": [2, { "words": true, "nonwords": false }],
        "spaced-line-comment": [2, "always"],
    },
    "env":{
        "mocha": true,
        "node": true
    }
}

How to release card if X distance is reached?

Hello,

I'm trying to release card once X distance is reached. So you can't drag more than your throwOutConfidence. Card should get released if distance is more than throw out confidence.
What I tried so far is

eventEmitter.on('_panmove', function (e) {
        var x = lastTranslate.x + e.deltaX,
            y = lastTranslate.y + e.deltaY,
            r = config.rotation(x, y, targetElement, config.maxRotation);

            if(e.deltaX > 150 || e.deltaX < -150 )  card.throwOut(x, y);

        config.transform(targetElement, x, y, r);

        eventEmitter.trigger('dragmove', {
            target: targetElement,
            throwOutConfidence: config.throwOutConfidence(x, targetElement),
            throwDirection: x < 0 ? Card.DIRECTION_LEFT : Card.DIRECTION_RIGHT
        });

 });

I try to throw out the card once it reached x distance, but this calls the function multiple times, as it's gets triggered few times while dragging.

I'm

Possible issue with touch input

Just in my Chrome Dev tools if I use touch events, the drag animation is quite choppy, and then goes smooth again as soon as the card is released. I love this library and plan on using it for a little mobile app that I'm doing.. I'l dive in and see if I can figure it out myself, but thought I'd open an issue just to verify that other people are having the same issue.

Thanks again for the repo!!

Throwing out at top and bottom should be possible too

If you drag a card to the top or to the bottom of the screen outside the container, the card current does not get thrown out. Instead it returns to its place. It should be configurable which directions should trigger a throw-out and which doesnt. Sometimes you would like to have top/down only or something different.

AMD surport?

Hi,I am trying to use this project on a AMD project,can you provide an AMD version?

TypeError: spring is undefined

I use keyup to handle card:

if(e.keyCode == 37)
{
card.throwOut(-200, 0);
}

stack.on('throwoutleft', function (e) {
card.destroy();
}

And i got bug: TypeError: spring is undefined
Please help me. Thank so much!

hammer event value comes back Nan

swing is awesome, i'm developing a tinder like app, but i seem to have a problem with swing, i always have 2 cards, when the first one is thrown out i remove it from the stack and add a new one, with that everything is okay, but randomly the hammer events starts to give out NaN in the deltaX and deltaY variables, the panmove event stop working, any ideia why this is happening?

Add time to card.throwOut()/ card.throwIn()

Thanks for this amazing code, it work excellent on mobile devices.
How I can add time when I ThrowOut()/throwIn() a card.
I need to to make something similar to this:

   card.throwOut(100, 500,3000);//where 3000 is the time(ms) that card will take to be in the position (100,500), like in css (transition :3s;)

Thank you again.

Disable reordering of 'li' elements

How would it be possible to disable the reordering of 'li' elements when clicking on a card which is not on the top of the stack. As of right now, when I click on the second card 'ul' reorders itself and the second card comes on top.

Dynamically adding and removing cards from the stack

I've got the cards working perfectly in a prototype Meteor.js app, and I'm trying to add and remove elements from the stack. I haven't spent too much time trying, but I thought it might make a good example. Thanks again!

Configure Bounce/Spring Feature

Is there a configuration option to remove the bounce feature when you let go of a card and it bounces back into place (with throwout or throwin)? It would be great if we could configure both bounces for throwout and throwin events separately.

For example, I'd like to have a spring/bounce when the card is thrown onto the stack but not when it is thrown off the stack (because I want to do some other custom animation to make it fly off the screen and the spring makes it bounce back before the animation kicks in).

Images inside card - drag issues

So I am attempting to use Swing to build a bespoke, trading card style app.

I am using the "cards" to hold images and a bit of text.

If I drag the card by clicking in some white space, or on the text, the card moves properly and it looks great.

However, if I click and drag on the image, the card does not move. Instead I see the "placeholder" image moving (like when you click and drag any image in a browser).

When I let go, the card quickly zips into place.

I would like for users to be able to drag by click-dragging the image.

Allow only horizontal dragging.

Hello, wondering if it's possible to restrict dragging to X axis only?
Issue I get is that I try to scroll down the page on the phone and it drags the element, I would like to make so, it allows you drag page down without garbing the element.

Restrict Y axis placement?

When I drag a card out of the pile, I can place it quite high above the pile, or quite below, on the Y axis.

Is there a way to limit the range on the Y axis so card appear more "in line" with the pile?

Example (see how far down I can place a card)

Adding new LI element to the bottom of the stack

How can I dynamically add a new card to the bottom of the stack with UL/LI?

Currently when I try the following, it reorders the list and new cards appear on the top of the stack.

  1. Adding LI element to the beginning of the UL
  2. Creating new card from the LI
  3. UL gets reordered, newly added LI element is being sent to the top of the stack

Thanks

Reduce the distance before card is thrown

Hello all,

Sorry for my naivety - I'm sure this is extremely simple but I can't seem to get it to function correctly. What do I need to put in the config to reduce the distance the user must move the card before it's considered thrown?

Kind regards,
Ben

What is the a reason li elements change z-index?

When you throw in and throw out cards it moves its position in the DOM

This makes it really difficult if you are using something like handlebars to render stuff.
So is there a reason why the position in the Elements are moved? something to do with z-index?

Question: How to get Sister events in Meteor?

I am trying to get Swing into a meteor app, but meteor will not pickup the custom events triggered by Sister.

I also tried stack.on('throwout', function (e) { but that is not fired too.

Performance issues

Are there any guidelines to how to use this efficiently?

On an iPhone (& Mac), if the cards are near to full screen and contain more content than the ones in the demo the FPS drops quite dramatically & very noticeably.

Maybe it may be smoother with css3 movement/similar to how famo.us does it?

I took the stack demo to play around and added some content in, made the cards full screen and it was near unusable.

Make only the top card swipeable

Any idea how we can limit to one card being swipeable, the top card? I can think of a quick and dirty fix but i am sure there must be an easier way to do this and make only the card on top swipable.

If any help, it would be much appreciated. I might actually just try to implement this my self and add a option to the stack config. any help would be appreciated . Thank you

gulp build-browser - SyntaxError: Unexpected reserved word

I'm looking to add swipe top and bottom functionality.

I've added code to src, when I try to gulp build-browser while in the bower-components/swing folder of my project, I get a SyntaxError: Unexpected reserved word on "import" from import gulp from 'gulp'.

Do you know what's happening here? What's the best way to test edits before a PR?

Cheers,
Johnny

Simple method to return cards to stack

Maybe I'm missing something but it seems like there isn't a simple way to return cards. Instead, you have to throw a new set of cards back in. Is this correct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.