-
-
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
Issue #3731 #12016 carousel keyboard rebased #13185
Issue #3731 #12016 carousel keyboard rebased #13185
Conversation
…ly cycle, then keyboard input doesn't work anymore".
a demo can be seen here : http://jsbin.com/eneRULi/11 |
I just viewed this http://jsbin.com/eneRULi/11
so please fix this and I would like to test this keyboard support and give my feedback. thanks. |
@hnrch02 yeh, thanks for your help. And also @saas786 , this is the updated version, with the simplifications suggested by fat. http://jsbin.com/eneRULi/32 |
could you squash these @francis-liberty ? thanks! |
$(document).on('keydown', '[data-ride="carousel"]', function (e) { | ||
// get the direction based on keyboard input | ||
var type = e.which == 37 ? 'prev' : | ||
e.which == 38 ? 'first' : |
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.
could you line these lines up with the first line… so the ?
etc are all lined up? would appreciate it :)
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.
@fat You mean like this? Of course I can do this.
var type = e.which == 37 ? 'prev' :
e.which == 38 ? 'first' :
e.which == 39 ? 'next' :
e.which == 40 ? 'last' : false
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.
yes please, thanks
@fat Just to confirm: So aside from the squashing and that one style issue, you'd be okay with merging this, correct? |
@@ -195,6 +195,28 @@ | |||
e.preventDefault() | |||
}) | |||
|
|||
$(document).on('keydown', '[data-ride="carousel"]', function (e) { |
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 is kinda expensive… basically on all keydowns we now have to query the entire dom… checking every elements for a data attribute… not the quickest expression.
might be better to have this in the carousel instance…
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.
@fat How about
$('[data-ride="carousel"]').on('keydown', function (e) {
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.
that doesn't effect carousels added after load, so that's not really good either
@cvrebert pretty much… slightly concerned about the global key listener. kinda rough hit to anyone using bootstrap for a feature that probably wont be taken advantage of that much. Might be better to tie it directly into the carousel instance and have it only setup on instantiation |
@fat Ah. I was/am just looking for places where I can speed up the PR process by rebasing and fixing minor style issues for folks, thus avoiding some back-and-forth delay. |
@francis-liberty good work, I like it now. As @fat pointed out, its better if we avoid global initiation. I would suggest if we go optional way, I mean if we make it optional and only execute if user pass parameters for keyboard support like https://github.com/woothemes/FlexSlider/blob/master/jquery.flexslider.js#L1090 this is best way (in my opinion) for this feature. and this kind of conditional implementation is recommended by me. https://github.com/woothemes/FlexSlider/blob/master/jquery.flexslider.js#L96 |
@@ -70,7 +70,7 @@ | |||
|
|||
<!-- Carousel | |||
================================================== --> | |||
<div id="myCarousel" class="carousel slide" data-ride="carousel"> | |||
<div id="myCarousel" class="carousel slide" data-ride="carousel" tabindex='-1'> |
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.
Per our code style guide, please use double-quotes in HTML.
@cvrebert I read your links, just to make it clear, you mean something like this? (of course I can move the big block of keydown event function outside the constructor, I just want to make a point here.)
|
@francis-liberty I'm not sure what links you're referring to. I had no feedback to offer regarding your JS. |
@francis-liberty yes something like that, but outside of main constructor (better if you can make it similar to Flexslider as per my links above, keyboard feature). |
closing in favor to this pr: #13787 thanks for the work @francis-liberty! |
fix #13185 - keyboard support for carousel
As @XhmikosR said, I've rebased this branch #12052 , squashed old 3 commits, and simplified the code as @fat kindly pointed out. But since I got rebase conflicts (the docs is split into separated files), I ended up a new PR .