Forums

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

Home Forums JavaScript anything slider numbers to text Re: anything slider numbers to text

#81437
oneworld95
Member

You’d put the formatText() function and the array declaration above the main AnythingSlider function call, so it will all look like this:

Code:
var nameArray = new Array("Name 1","Name 2","Name 3","Name 4","Name 5","Name 6");

function formatText(index, panel){
var myHtml = "<div class=’myDiv’>My text for Panel #" + index + " is " + nameArray[index] + "</div>";
return myHtml;
}

// Instantiate the AnythingSlider and set properties.
$(function () {

$(‘.anythingSlider’).anythingSlider({
easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin
autoPlay: true, // This turns off the entire FUNCTIONALY, not just if it starts running or not.
delay: 4000, // How long between slide transitions in AutoPlay mode
startStopped: false, // If autoPlay is on, this can force it to start stopped
animationTime: 600, // How long the slide transition takes
hashTags: false, // Should links change the hashtag in the URL?
buildNavigation: true, // If true, builds and list of anchor links to link to each slide
pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover
startText: "Go", // Start text
stopText: "Stop", // Stop text
navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
});

});

Note that we’ve changed the value of the property "navigationFormatter" from null to the name of the function that sets the HTML for the nav buttons; it’s now set to formatText