-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Add touch support in our carousel #25776
Conversation
6951e04
to
e91aee5
Compare
Its quite a big addition... Can't we do the basic stuff ourselves? |
_includes/scripts.html
Outdated
@@ -2,6 +2,8 @@ | |||
<script>window.jQuery || document.write('<script src="{{ site.baseurl }}/assets/js/vendor/jquery-slim.min.js"><\/script>')</script> | |||
|
|||
<script src="{{ site.baseurl }}/assets/js/vendor/popper.min.js"{% if site.github %} integrity="{{ site.cdn.popper_hash }}" crossorigin="anonymous"{% endif %}></script> | |||
<script src="{{ site.baseurl }}/assets/js/vendor/hammer.min.js"{% if site.github %} integrity="{{ site.cdn.hammer_hash }}" crossorigin="anonymous"{% endif %}></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add it in package.json (uglify) too for the docs package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange but Popper isn't in our doc-minify
task 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, indeed. Just leave it as is and I'll give it a go in the next days and let you know. :)
I don't think it's a big change here, we add an optionnal lib, if folks need a touch support that's all |
Sure, but can't we have the basic functionality without a 20 KB file? I recall you had a branch in the past. |
This won't be added in our dist files, so we won't add 20 kb I'm not in favor of adding logics about touch detection and swipe detection when they are libs which can do that better than me |
I agree on that, but then one would say why don't you support jQuery mobile or whatever other lib there's out there. Anyway, I'm not against this, I just want us to think it through. |
I think HammerJS is a good choice, Angular chose HammerJS too |
a8b3276
to
89fcc36
Compare
js/src/carousel.js
Outdated
if (this._config.keyboard) { | ||
$(this._element) | ||
.on(Event.KEYDOWN, (event) => this._keydown(event)) | ||
} | ||
|
||
if (touchSupported) { | ||
this.hammer.on(Event.SWIPELEFT, () => this.next()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't here a check quired if hammer support is enabled or the hammer reference exists to prevent a reference error? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's true nice catch 👍
502272d
to
bef1560
Compare
js/tests/index.html
Outdated
@@ -20,11 +20,15 @@ | |||
}()) | |||
</script> | |||
<script src="../../assets/js/vendor/popper.min.js"></script> | |||
<script src="../../assets/js/vendor/hammer.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe load this from node_modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that, it's a peerDependency
. How about using the CDN instead of adding yet one more file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep sure !
js/tests/karma.conf.js
Outdated
@@ -17,6 +17,8 @@ module.exports = (config) => { | |||
files: [ | |||
jqueryFile, | |||
'assets/js/vendor/popper.min.js', | |||
'assets/js/vendor/hammer.min.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed.
1c34111
to
5823397
Compare
@patrickhlauke everything is fine now, can you confirm it ? Thanks 👍 |
8bcaeb3
to
652161f
Compare
652161f
to
098d089
Compare
i can have one last actual live test later tonight on my phones and Surface, but conceptually this all looks good to me now |
It works fine for me 👍 /CC @XhmikosR if you want to do some tests too |
https://deploy-preview-25776--twbs-bootstrap4.netlify.com/docs/4.1/components/carousel/ seems to be working fine now (tested there as i've not got my build/test environment all set up again at the moment) ... but man, the aggressive caching/service worker really gets in the way of quickly checking changes out sometimes... possibly more related to netlify here: on IE11 and Edge, I found that the carousels are unresponsive for quite a long time after page load (unless you kick them into action if there are the "<" / ">" controls). it seems the browser is waiting for some file to load from the network, and only once it gives up does it run the onload stuff. |
There is actually no service worker on netlify; it doesn't run the production scripts on purpose. |
i found i had to force refresh (and in the case of Firefox, go in and delete session storage etc) while testing. not quite sure why then...aggressive caching? i see pwa.js is loaded as well if that means anything...i'm actually not sure if this is related to service worker or not. in any case, it seems to be the carbon ads json that is never loaded (shows as "(pending)" in the F12 tools' network tab). only once the browser gives up trying to load it is the JS on page load actually executed. anyway, that's all tangential. the carousel swipe thing now seems to work nicely |
This no longer works for me with Firefox 63 devtools and say S9 emulation. It works fine with Chrome though. |
@XhmikosR that's strange it works perfectly on my Android with Firefox |
Well a real touch device is not the same as the emulator :) That being said I don't know if we should even care about it. I just thought I'd report it since Firefox is my main browser and this worked in the previous patches. |
I think we should test using BrowserStack here |
The reason why it's not working in Firefox's device emulation is that we check for
[edit: filed a bug here: Bug 1500672 - Responsive Design Mode with touch simulation: navigator.maxTouchPoints still zero] |
All right, let's merge this then. Great work everyone! |
Fixes: #17118