Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript callbacks in AnythingSlider when using swipe addon

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #145516

    I have a project that I intend to either use touchwipe of jQuery swipe. My issue is that in all the documentation it seems like you can only call goForward or goBackward when binding the touchswipe. But goForward doesn’t fire-off all my code under OnSlideBegin. The reason I need this is I have the slider change when it reaches the end (when you click forward on the last slide it replaces all the slides with a new set (sets are dynamically picked with XML).

    How can I get the swipes to trigger the functions bound to the arrows? I thought clickForwardArrow: “click swiperight”, might work but that seems mean when you swipe on the arrow, not the slider window (unless I am doing something wrong).

    HERE IS MY CODE:
    function setSlider(a){
    $(‘#slider’).anythingSlider({
    buildArrows : true,
    enableArrows : true,
    enableNavigation : true,
    buildNavigation : true,
    buildStartStop : false,
    hashTags : false,
    startPanel : a,

        onInitialized: function(e, slider) {
            $('#slider').hide();
    
            $('#slider').fadeIn(500);
    
            $("#slider").touchwipe({
                wipeLeft: function() {slider.goForward();},
                wipeRight: function() {slider.goBack();},
                min_move_x: 20,
                preventDefaultEvents: true
            }); 
    
        },
    
        onSlideBegin: function(e, slider) {
            $(".bt-wrapper").hide();
            var whichOne;
            $("#ui_container").click(function(event){
                whichOne = $(event.target).parent().attr("class");
    
                if(slider.pages > 2){
                    if (slider.currentPage == slider.pages && slider.targetPage == 1 && slider.targetPage != slider.exactPage){ 
                        if (curSec < setArray.length - 1){
                            curSec = curSec + 1;
                        }else if (curSec == setArray.length - 1){
                            curSec = 0;
                        }
                        slideBuilder(curSec,false);
                    }else if (slider.currentPage == 1 && slider.targetPage == slider.pages && slider.targetPage != slider.exactPage){
                        if (curSec >= 1){
                            curSec = curSec - 1;
                            slideBuilder(curSec,true);
                        }else if (curSec == 0){
                            curSec = setArray.length - 1;
                            slideBuilder(curSec,true);
                        }
                    }
                }else{
                    if (slider.currentPage == 2 && slider.targetPage == 1 && slider.targetPage != slider.exactPage){ 
                        if (curSec < setArray.length - 1){
                            curSec = curSec + 1;
                        }else if (curSec == setArray.length - 1){
                            curSec = 0;
                        }
                        slideBuilder(curSec,false);
                    }else if (slider.currentPage == 1 && slider.targetPage == slider.pages && slider.targetPage != slider.exactPage){
                        if (curSec >= 1){
                            curSec = curSec - 1;
                            slideBuilder(curSec,true);
                        }else if (curSec == 0){
                            curSec = setArray.length - 1;
                            slideBuilder(curSec,true);
                        }
                    }
                }
                $("#ui_container").unbind('click');
            });
        },
    });
    

    }

    #146032

    I found a solution.

    I wrote this function:

    function addSwipe(){
    $(".anythingWindow").swiperight(function() {
        $(".back a").trigger("click");
    });
    $(".anythingWindow").swipeleft(function() {
        $(".forward a").trigger("click");
    });
    

    }

    and call it at “onInitialized”.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.