WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Stop slider auto-advancing? (15 posts)

  1. studioALSO
    Member
    Posted 11 months ago #

    Hello,

    I've searched and Googled around for a while now, but I can't seem to find the answer to what seemed to me a straightforward question: is it possible to set-up the Customizr slider to NOT auto-advance at all? (And if so, how? :P)

    I would like to use the slider as a navigational element, and remain on the main image until the user decides to click on one of the navigational arrows.

    Thanks a lot!

  2. rdellconsulting
    Member
    Posted 11 months ago #

    If you only use a single image slider, it might work?

  3. studioALSO
    Member
    Posted 11 months ago #

    Thank you, but unfortunately I do want my slider to have 3 (or more) images.

    The current very early concept at http://www.studio-also.com/ should explain what I'm trying to achieve more clearly.

    Upon arriving at the site, the initial slide image shows the two sections, and clicking on the forward or back arrows would switch the slide image to the appropriate section.

    The concept works well, but the auto-advancing slider limits functionality and breaks the "illusion" of a user-decided navigation.

    I'd basically like a slide delay of "forever", or a "pause forever" rather than just on hover, but part of me expected there might be an easier solution--although I would not be surprised if it turned out to be either far more complicated or impossible.

  4. rdellconsulting
    Member
    Posted 11 months ago #

    The code can be found in /parts/class-content-slider.php but the delay is in js/tc-scripts.js.

    As I'm not familiar with javaascript, someone else will hopefully pick up and resolve this for you.

    I like your design btw!

  5. d4z_c0nf
    Member
    Posted 11 months ago #

    Actually an option to avoid the autoadvance would be useful. I can suggest you a hack (not a difficult one) if you feel like to modify a javascript file.

  6. rdellconsulting
    Member
    Posted 11 months ago #

    @d4z, any chance we can write a snippet similar to this one from Nic?

  7. d4z_c0nf
    Member
    Posted 11 months ago #

    @rdellconsulting, I tell you, my solution was rough. Since there's not an option to avoid the auto-advancing I thought this:
    - in tc-scripts.min.js, make a check on delay option length, and if is 1 (1 digit), then call the carousel setting interval:false.

    This way one can set the delay in sliders options to a number of 1 digit (but not 0, you can't, there might be a check that prevents that), and that's enough.

    About write a snippet similar to that, don't know, I'm not a js expert, I will figure out...

  8. d4z_c0nf
    Member
    Posted 11 months ago #

    This seems to work. But I told you, I'm not a js expert, and don't know if there might be a better way (anyway, as you can see, I copied much of nic snippet):

    add_action('wp_footer', 'disable_slides_auto_advancing');
    function disable_slides_auto_advancing(){
        global $wp_query;
        $queried_id = get_queried_object_id();
        $queried_id = ( !tc__f('__is_home') && $wp_query -> is_posts_page && !empty($queried_id) ) ?  $queried_id : get_the_ID();
        $slider_active  = esc_attr(get_post_meta( $queried_id, $key = 'post_slider_check_key' , $single = true ));
        if ( tc__f('__is_home') && tc__f('__get_option','tc_front_slider') !=null) {
           $slider_active = true;
        }
        if(!$slider_active) {
            return;
        }
        //create an array with pages id in which we don't want sliders auto-advancing
        $page_sliders = array(
    	//page_id
    	17,
    	4
        );
        // if one uses a non-static front page
        // should be added " || tc__f('__is_home')" to the following condition
        if ( in_array( $queried_id, $page_sliders ) ):
    ?>
    	<script type='text/javascript'>
                jQuery(document).ready(function() {
                    ! function ($) {
    		    //prevents js conflicts
    		    "use strict";
    
    		    $.NoAutoAdvance = function () {
    		        $("#customizr-slider").carousel({
    			    interval: false
    			});
    		    };
    		}(window.jQuery);
    		//calls the function
    		jQuery.NoAutoAdvance();
                });
    	</script>
    <?php
        endif;
    }
  9. d4z_c0nf
    Member
    Posted 11 months ago #

    @studioALSO
    Just paste the code above in your child theme functions.php - a file in your child theme directory named functions.php [if it doesn't exist, create it] which has to start with
    <?php

    Since, if I'm not wrong, you use a static front page (id=4), then you don't need that 17 in the $page_sliders array, so that array will become:

    $page_sliders = array(
    	//page_id
    	4
        );

    Hope this helps.

  10. studioALSO
    Member
    Posted 11 months ago #

    @rdellconsulting Thanks for the reply and kind words, I'm trying to do something a little different with this flexible theme, and it's always nice to hear someone else's response to it--seems like I'm on the right track!

    @d4z_c0nf Thank you for the suggestion, I'll try it out the next time I have the chance! You were not wrong about the static front page, btw ;)

  11. ElectricFeet
    Member
    Posted 11 months ago #

    A more pragmatic solution would be to change the delay between slides in the Front Page panel of Customiz'it to 9999999999 (any more digits than that and the number wraps and it advances very quickly).

    If nothing else, it'll scare the hell out of someone who leaves your page open in their browser for 3 months, when the slide suddenly advances :-)

  12. d4z_c0nf
    Member
    Posted 11 months ago #

    :D
    I though about other 2 ways to do that.
    One of them couldn't be implemented without changing tc-scripts.js. Basically you can't pass boolean false as delay param since wp_localize_script passes params as string, and it will be misinterpreted by boostrap.js.
    The other one was override that param, simply printing a script in the footer (as wp_localize_script does) with TCParams.SliderDelay = false
    But.. is appropriate to say..

    Everybody needs a pragmatic!

  13. studioALSO
    Member
    Posted 11 months ago #

    I am a big fan of pragmatism myself :)

    While I'm messing around with every other aspect of the site, I'll think I'll stick with ElectricFeet's easy-to-implement suggestion, which seems to work well. (Although the Customiz'it menu only appears to "show" 5 digits, it does seem to stay on the same slide for longer than the expected 16.66 minutes if that were true, so it appears to work well enough :P)

    I think I'll probably look into this some more at a later stage and see about a more "proper" solution, so thank you for the suggestions, d4z_c0nf!

  14. d4z_c0nf
    Member
    Posted 11 months ago #

    Yep ElectricFeet's solution is the better.
    Don't use mine, it's not worthwhile :D

  15. ElectricFeet
    Member
    Posted 11 months ago #

    9999999999 is over 3.5 months. "Proper" enough for me :-)

Reply

You must log in to post.

About this Theme

About this Topic