Home › Forums › JavaScript › Text Slider
- This topic is empty.
-
AuthorPosts
-
December 18, 2013 at 5:27 pm #158662
chrisburton
ParticipantI have this reduced case:
Full: http://codepen.io/chrisburton/full/kqgsb Editor: http://codepen.io/chrisburton/pen/kqgsb
The middle column should have a slide functionality while the others (first and third columns) are static content. Each paragraph will be an individual slide if that makes sense.
I’m trying to find a very basic text slider that will slide on click and also have an auto-play feature.
I’ve tried NivoSlider, bxslider, unoSlider and Anything Slider. None worked for me. Any ideas?
December 18, 2013 at 10:20 pm #158681TheDoc
MemberThe
<p>
s will need to be display block or at the minimum have a wrapper instead. I’m not fully sure what you want this to look like, though!Should work with any slider out there, though! Can you post an example of you trying out one of the plugins? What goes wrong?
December 18, 2013 at 11:03 pm #158692chrisburton
ParticipantSure. Let me try adding another slider.
@Joe No, not really. Your slider goes up which I think requires jQuery UI. I just need something really simple. I’m going to try creating my own version first, really quick.
I’ll post back.
December 18, 2013 at 11:41 pm #158701chrisburton
ParticipantOkay. I updated the Pen with what I’m trying to accomplish. However, this probably won’t work if there are more than two paragraphs.
http://codepen.io/chrisburton/pen/kqgsb
Click the middle column paragraph to see the functionality I’m looking for.
December 19, 2013 at 12:28 am #158703chrisburton
ParticipantI’m not following? I’m trying to cycle through a dynamic set of paragraphs.
I think what I may need here is a variable that tells jQuery how many paragraphs I have (i++?) and then auto-cycles through all of those every so many seconds and or clicks.
December 19, 2013 at 12:34 pm #158784__
ParticipantMaybe like so?
#slider p{ display: none; } #slider .show{ display: block; }
(You’d need to add the class
show
to whichever paragraph you want displayed by default.)var $p = $("#slider p"); $p.each(function(i,e){ $e = $(e); var nextP = (i+1 >= $p.length)? 0: i+1; console.log(nextP); var $nextP = $($p[nextP]); $e.on("click",function(e){ $(this).removeClass("show"); $nextP.addClass("show"); }); });
December 19, 2013 at 6:56 pm #158817chrisburton
ParticipantWhat about cycling through like an auto-play feature? That’s what I’ve been trying to figure out.
Also, I’m not sure that would be possible to add a class of show. This is WP and the
<p>
tags are auto-generated.December 19, 2013 at 8:51 pm #158832__
ParticipantWhat about cycling through like an auto-play feature? That’s what I’ve been trying to figure out.
I’m sure it could be done… maybe turn the event handler into a function for
setInterval
.Also, I’m not sure that would be possible to add a class of show. This is WP and the
<p>
tags are auto-generated.You could add it via javascript. In fact, you could add the relevant CSS at the same time, so everything would be visible in the case that js was disabled.
December 19, 2013 at 9:23 pm #158833chrisburton
ParticipantGood point. Thanks @traq.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.