Skip to content

Add touch support in our carousel - #25776

Merged
XhmikosR merged 12 commits into
v4-devfrom
v4-carousel-hammer
Oct 20, 2018
Merged

XhmikosR merged 12 commits into
v4-devfrom
v4-carousel-hammer

Conversation

@Johann-S

@Johann-S Johann-S commented Mar 3, 2018 •

Copy link
Copy Markdown
Member
  • Add unit test
  • Documentation

Fixes: #17118

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 2 times, most recently from 6951e04 to e91aee5 Compare March 3, 2018 21:15
@XhmikosR

XhmikosR commented Mar 3, 2018

Copy link
Copy Markdown
Member

Its quite a big addition... Can't we do the basic stuff ourselves?

Comment thread _includes/scripts.html Outdated

@XhmikosR XhmikosR Mar 3, 2018 •

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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 🤔

Copy link
Copy Markdown
Member

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. :)

@Johann-S

Johann-S commented Mar 3, 2018

Copy link
Copy Markdown
Member Author

I don't think it's a big change here, we add an optionnal lib, if folks need a touch support that's all

@XhmikosR

XhmikosR commented Mar 3, 2018

Copy link
Copy Markdown
Member

Sure, but can't we have the basic functionality without a 20 KB file? I recall you had a branch in the past.

@Johann-S

Johann-S commented Mar 3, 2018

Copy link
Copy Markdown
Member Author

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

@XhmikosR

XhmikosR commented Mar 3, 2018

Copy link
Copy Markdown
Member

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.

@Johann-S

Johann-S commented Mar 3, 2018

Copy link
Copy Markdown
Member Author

I think HammerJS is a good choice, Angular chose HammerJS too

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 2 times, most recently from a8b3276 to 89fcc36 Compare March 4, 2018 00:05
Comment thread js/src/carousel.js Outdated
}

if (touchSupported) {
this.hammer.on(Event.SWIPELEFT, () => this.next())

Copy link
Copy Markdown
Contributor

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? 🤔

Copy link
Copy Markdown
Member Author

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 👍

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 2 times, most recently from 502272d to bef1560 Compare March 4, 2018 16:28
@Johann-S Johann-S changed the title WIP: Add touch support on our carousel with Hammer Add touch support on our carousel with Hammer Mar 4, 2018
Comment thread js/tests/index.html Outdated
}())
</script>
<script src="../../assets/js/vendor/popper.min.js"></script>
<script src="../../assets/js/vendor/hammer.min.js"></script>

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep sure !

Comment thread js/tests/karma.conf.js Outdated
files: [
jqueryFile,
'assets/js/vendor/popper.min.js',
'assets/js/vendor/hammer.min.js',

Copy link
Copy Markdown
Member

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.

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 2 times, most recently from 1c34111 to 5823397 Compare April 10, 2018 07:50
@XhmikosR

This comment has been minimized.

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch from 5823397 to 43ab415 Compare July 2, 2018 12:02
@Johann-S

This comment has been minimized.

@Johann-S

Copy link
Copy Markdown
Member Author

@patrickhlauke I cleaned a bit the git history and squashed some of your commits

@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 2 times, most recently from 2acb4a3 to 625c697 Compare October 16, 2018 10:00
@Johann-S

Copy link
Copy Markdown
Member Author

@patrickhlauke everything is fine now, can you confirm it ? Thanks 👍

Comment thread js/src/carousel.js Outdated
@Johann-S
Johann-S force-pushed the v4-carousel-hammer branch 3 times, most recently from 8bcaeb3 to 652161f Compare October 16, 2018 11:46
@patrickhlauke

Copy link
Copy Markdown
Member

i can have one last actual live test later tonight on my phones and Surface, but conceptually this all looks good to me now

@Johann-S

Copy link
Copy Markdown
Member Author

It works fine for me 👍

/CC @XhmikosR if you want to do some tests too

@patrickhlauke

Copy link
Copy Markdown
Member

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.

@XhmikosR

Copy link
Copy Markdown
Member

There is actually no service worker on netlify; it doesn't run the production scripts on purpose.

@patrickhlauke

Copy link
Copy Markdown
Member

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

@XhmikosR

Copy link
Copy Markdown
Member

Correction, the service worker is being there albeit broken on dev mode. I definitely need to finish #26868 and #27320.

I'm gonna look into this branch later and get back to you guys.

@XhmikosR

Copy link
Copy Markdown
Member

This no longer works for me with Firefox 63 devtools and say S9 emulation. It works fine with Chrome though.

@Johann-S

Copy link
Copy Markdown
Member Author

@XhmikosR that's strange it works perfectly on my Android with Firefox

@XhmikosR

Copy link
Copy Markdown
Member

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.

@Johann-S

Copy link
Copy Markdown
Member Author

I think we should test using BrowserStack here

@patrickhlauke

patrickhlauke commented Oct 20, 2018 •

Copy link
Copy Markdown
Member

The reason why it's not working in Firefox's device emulation is that we check for navigator.maxTouchPoints (part of the pointer events spec), but device emulation doesn't fake this value. So touchSupported evaluates to false in the code, and none of the swipe code is attached. tl;dr: it's the fault of Firefox's emulation.

firefox-devtools-emulation-touch
https://patrickhlauke.github.io/touch/tests/pointer-multitouch-detect.html

[edit: filed a bug here: Bug 1500672 - Responsive Design Mode with touch simulation: navigator.maxTouchPoints still zero]

@mdo mdo mentioned this pull request Oct 20, 2018
@XhmikosR

Copy link
Copy Markdown
Member

All right, let's merge this then. Great work everyone!

@XhmikosR XhmikosR changed the title Add touch support on our carousel Add touch support in our carousel Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants