Closed jespirit closed 5 years ago
Some of the touch event unit tests check whether a event listener was called more than once. What's the best way to handle that in an asynchronous way?
it("slider should not have duplicate events after calling 'refresh'", function() {
touch.initEvent("touchstop");
flag = 0;
testSlider.on('slideStop', function() {
flag += 1;
});
testSlider.slider('refresh');
testSlider.data('slider')._mouseup(mouse);
expect(flag).toEqual(1);
});
I used a fake 'temp'
event with a temporary handler that I call with .trigger()
.
it("slider should not have duplicate events after calling 'refresh'", function(done) {
flag = 0;
var tempHandler = function() {
// Remove this handler
testSlider.off('temp', tempHandler);
expect(flag).toBe(1);
done();
};
testSlider.on('slideStop', function() {
flag++;
});
sliderElem.dispatchEvent(touchStart);
sliderElem.dispatchEvent(touchMove);
sliderElem.dispatchEvent(touchEnd);
testSlider.slider('refresh');
testSlider.on('temp', tempHandler);
testSlider.trigger('temp');
});
@rovolution Is this code meant for browser compatibility and performance?
Its been a while, but I believe the original intention was to prevent duplicate events from being triggered...I vaguely remember it, but there was some case where a device was binding to both the touch and the regular mouse events, and was thus causing the same slider events to be emitted multiple times.
Any updates?
Any updates?
I have to write some unit tests and do more manual testing before I can merge this. I'll try to schedule some time to work on this hopefully next week because I know touch features are kind of broken.
Is there any news on this?
Please fix, we are thankful 😊
Sorry, I've been busy with school. I'll have some time tomorrow to work on it.
This is a major pull request and there are a lack of unit tests for touch capability. I don't want to publish code that isn't tested properly. I don't really have a way of knowing whether this works on real devices. I don't have access to an iPhone or iPad.
I'll work on setting up deploy previews so we can test this more easily.
Next time this PR is pushed to, there should be a deploy preview. I can help validate this on my devices and hopefully some in this thread can help as well.
Thanks!
@seiyria that will be awesome! I just did a quick read on Netlify and it looks super cool!
That would be great, a lot of ecommerce shops run on this plugin.
@jespirit did you try rebasing this topic branch against the current master branch? i think that may be why the netifly preview is failing cc: @seiyria
I rebased. It was messy though. I'm glad it didn't break any tests.
@jespirit is this good to go? did you QA the deploy preview in Netlify?
https://deploy-preview-899--bootstrap-slider.netlify.com/
Also remember to remove the console.logs
from the source code
It definitely passes the manual QA. I've only tested on Google Chrome Dev tools and my Samsung A5.
I just need to add a few more basic tests (plus remove debug statements) then I think it's good to merge.
@jespirit Replace blue with blur ! Thanks for fixing mobile bug
@jespirit Replace blue with blur ! Thanks for fixing mobile bug
![]()
Nice catch. Thanks for that.
I will have time on Wednesday to write the tests and soon after merge it.
Done.
codeclimate
would not be happy about the unit tests
This pull request addresses these issues:
Page scrolling: https://github.com/seiyria/bootstrap-slider/issues/639 Passive listeners: https://github.com/seiyria/bootstrap-slider/issues/842
Tooltips not displaying on touch-enabled mobile devices: https://github.com/seiyria/bootstrap-slider/issues/513 https://github.com/seiyria/bootstrap-slider/issues/765
_touchstart()
and_touchmove()
just to see if the code would work. @rovolution Is this code meant for browser compatibility and performance? https://github.com/seiyria/bootstrap-slider/blob/642b40f80790b7c82e9ff149cdf07e40907ccd34/src/js/bootstrap-slider.js#L1585-L1594 https://github.com/seiyria/bootstrap-slider/blob/642b40f80790b7c82e9ff149cdf07e40907ccd34/src/js/bootstrap-slider.js#L1683-L1703dist
folder so I can demo the changes on my project pageYou can check my project page to test the latest changes from this branch: https://jespirit.github.io/bootstrap-slider/. I've tested it mobile devices using Chrome's Device Mode.
I also tested it on my Samsung A5 (2017), Android 8.0.0
Unit tests...
Edit:
preventDefault()
inside of'touchmove'
event will prevent the page from scrolling and will not send a corresponding'mousemove'
. However, event listeners are set up in_mousedown()
to call_mousemove()
on'touchmove'
events. https://github.com/seiyria/bootstrap-slider/blob/642b40f80790b7c82e9ff149cdf07e40907ccd34/src/js/bootstrap-slider.js#L1561-L1565Pull Requests
Please accompany all pull requests with the following (where appropriate):
grunt test
in your Terminal within the bootstrap-slider repository directory