-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(carousel): Support swipe for touchscreen devices #1686
Conversation
Would offer support for #1416. |
Touch support is absolutely awesome, but that is adding a new dep so I think we should think about our goals about touch stuff. |
@Foxandxss A solution would be to leave it up to people themselves whether or not they want to add touch support. Because when you don't load ngTouch the used directives will just become 'dumb' attribute. Though there still is some small overhead of the unused attributes in the template that way. |
I could live wit that tbh, is the cleanest way I think. |
👍 The main thing I would do is simplify the tests. Right now you are more testing that the I would instead make mock versions of ngSwipeLeft and ngSwipeRight that are simple and easy to test.
describe('carousel swiping', function() {
beforeEach(module('ui.bootstrap.carousel', function($compileProvider, $provide) {
angular.forEach(['ngSwipeLeft', 'ngSwipeRight', makeMock);
function makeMock(name) {
$provide.value(name + 'Directive', []); //remove existing directive if it exists
$compileProvider.directive(name, function() {
return function(scope, element, attr) {
element.on(name, function() {
scope.$apply(attr[name]);
});
};
});
}
}));
//..other stuff to setup
it('should go next on swipeLeft', function() {
elm.triggerHandler('ngSwipeLeft');
//expectNextSlideToBeActive();
});
}); |
@Foxandxss I will change it as we discussed. @ajoslin It's true I borrowed a part of the test from Angular itself. I like what you're proposing as it's more future proof if things might change as you mentioned. |
@ajoslin I can't seem to get it working, I've included it inside the beforeEach(module('ui.bootstrap.carousel', function($compileProvider, $provide) {
angular.forEach(['ngSwipeLeft', 'ngSwipeRight'], makeMock);
function makeMock(name) {
$provide.value(name + 'Directive', []); //remove existing directive if it exists
$compileProvider.directive(name, function() {
return function(scope, element, attr) {
element.on(name, function() {
scope.$apply(attr[name]);
});
};
});
}
}));
describe('swiping', function() {
it('should go next on swipeLeft', function() {
testSlideActive(0);
elm.triggerHandler('ngSwipeLeft');
testSlideActive(1);
});
it('should go prev on swipeRight', function() {
testSlideActive(0);
elm.triggerHandler('ngSwipeRight');
testSlideActive(2);
});
}); |
hmm.. add some console.log in the fake directive (linking function and |
@ajoslin It's one of those days that you don't change a thing but it all of a sudden works! |
What do you guys think about the documentation for this? Don't mind the strange commit, I will rebase it later. |
I kinda made a mess of it and I can't seem to get everything back to a single commit. |
Now you want to 'squash' all of the commits after Now save and quit, and go through the screens it gives you and it will squash your commits together. |
Ok, I've squashed them all into one but when pushing I run into a non-fast-forward. |
So now you've modified your local repository in a way that the remote cannot recognize - because you "changed the history" of commits - erasing commits. This is OK to do on a development branch, but not good to do on master. You will want to do |
Everything should be fine now, I've also added some explanation about enabling touch. Thanks @ajoslin! I'm not really familiar with Git, which I hope to improve in the future. |
I Like it :) |
Pulled it down and changed a couple things:
Please be sure to test that the demo page works as expected in the future. Merged now. Thanks @Gamemaniak and please keep contributing! |
@ajoslin Things got a bit chaotic due to the rebasing I think. Of course I will keep contributing! |
👍 Open source is the bomb. Random people helping random people so everyone can make good things! |
Allows users on touchscreen devices to swipe to next and previous images in the carousel.