Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't throw out cards on iPhone #3

Open
tobiasmuecksch opened this issue Jan 3, 2015 · 10 comments
Open

Can't throw out cards on iPhone #3

tobiasmuecksch opened this issue Jan 3, 2015 · 10 comments

Comments

@tobiasmuecksch
Copy link

I'm using angular swing in an ionic app. It works perfectly so far. But currently I have the issue that I can't throw out cards in any direction. They just snap back. I only can throw cards out, if I touch them on the outmost edge in the opposite direction of which I'm throwing.
Is it possible to set a minimum distance a card has to be dragged to count as thrown out?

I hope I expressed my problem correctly :)

Thanks in advance!

@martinpfannemueller
Copy link

I got the same problem

@BrianPhilips
Copy link

i am also having the same problem, i am trying to config throwOutConfidence to be 0.5 but cant seem to do it using the configuration method in the swig documentation. Any help is much apreciated.

var stack,
    config;

config = {
    /**
     * Invoked in the event of dragmove.
     * Returns a value between 0 and 1 indicating the completeness of the throw out condition.
     * Ration of the absolute distance from the original card position and element width.
     * 
     * @param {Number} offset Distance from the dragStart.
     * @param {HTMLElement} element Element.
     * @return {Number}
     */
    throwOutConfidence: function (offset, element) {
        return Math.min(Math.abs(offset) / element.offsetWidth, 1);
    }
};

stack = stack = Swing.Stack(config);

@m10l
Copy link

m10l commented Mar 4, 2015

Try setting throwOutConfidence as this -

return Math.min(Math.abs(offset) / (element.offsetWidth / 2), 1);

@BrianPhilips
Copy link

Thank you @m10l
I understand how you would decrease the throwOutConfidence, but i don’t know where to call the TrowOutConfidence function. I am using the angular-swig implementation so i do not invoke the stack by calling Swing.Stack(config), when I try calling it from my controller I get Swing is not defined; I Am using the swing-card and swing-stack directive. Should I call it from within an event listener and try invoking it on the dragmove event like the commented section of the config object states (* Invoked in the event of dragmove.)?? I was able to get it to work by changing the TrowOutConfidence directly in angular-swing.js. but that is far from ideal.

@IVLMediaInc
Copy link

Also noticing this on mobile.

@thehashrocket
Copy link
Collaborator

did anyone get this working updating the config variables from within Angular?

@tobiasmuecksch
Copy link
Author

@jshultz I had to fork this directive and change it to suit my needs. Sadly there is no option to pass in configuration into the directive.

@thehashrocket
Copy link
Collaborator

@tobiasmuecksch : good to know, thank you. I guess I'm doing the same thing then. :)

@Lenndev
Copy link

Lenndev commented Jul 28, 2016

So, what is the best option to solve this? When I test it in normal view in chrome, I do get the bumping back and dnd effect, and with the solution @m10l
return Math.min(Math.abs(offset) / (element.offsetWidth / 2), 1)
inside my own controller and with swing-options="swingoptions" on the HTML element
``
$scope.swingoptions = {
throwOutConfidence: function (offset, element) {
console.log('throwOutConfidence', offset, element.offsetWidth);
return Math.min(Math.abs(offset) / (element.offsetWidth/2), 1);//solution of m10l
},
isThrowOut: function (offset, element, throwOutConfidence) {
console.log('isThrowOut', offset, element.offsetWidth, throwOutConfidence);
return throwOutConfidence === 1;
}
};

``
the cards do stay aside the stack.
Sadly enough, when I test it with dev tools ipad it doesn't work at all, is this just the dev tools?

@shmdesign
Copy link

In Vuejs in the config data i defined the following:

config: {
throwOutConfidence: (xOffset, yOffset, element) => {
const xConfidence = Math.min(Math.abs(xOffset) / (element.offsetWidth / 2), 1);
const yConfidence = Math.min(Math.abs(yOffset) / (element.offsetHeight / 2), 1);

                return Math.max(xConfidence, yConfidence);
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants