Hi. We previously had a page with several rotators on it. They were rotated from ButtonsOver which worked fine. We're now using FromCode as we needed to position the rotator button controls else where. Everything is working okay except when you initially mouseover the button control (first time), there is the normal FrameDuration of 700ms. We want it to start straight away like ButtonsOver without the initial delay. Thanks.
Daniel
JS
ASPX
Daniel
JS
function startRotator(clickedButton, rotator, direction) { |
if (!rotator.autoIntervalID) { |
refreshButtonsState(clickedButton, rotator); |
rotator.autoIntervalID = window.setInterval(function() { |
rotator.showNext(direction); |
}, rotator.get_frameDuration()); |
} |
} |
function stopRotator(clickedButton, rotator) { |
if (rotator.autoIntervalID) { |
refreshButtonsState(clickedButton, rotator) |
window.clearInterval(rotator.autoIntervalID); |
rotator.autoIntervalID = null; |
} |
} |
function showNextItem(clickedButton, rotator, direction) { |
rotator.showNext(direction); |
refreshButtonsState(clickedButton, rotator); |
} |
// Refreshes the Stop and Start buttons |
function refreshButtonsState(clickedButton, rotator) { |
var jQueryObject = $telerik.$; |
var className = jQueryObject(clickedButton).attr("class"); |
switch (className) { |
case "start": |
{// Start button is clicked |
jQueryObject(clickedButton).removeClass(); |
jQueryObject(clickedButton).addClass("startSelected"); |
// Find the stop button. stopButton is a jQuery object |
var stopButton = findSiblingButtonByClassName(clickedButton, "stopSelected"); |
if (stopButton) {// Changes the image of the stop button |
stopButton.removeClass(); |
stopButton.addClass("stop"); |
} |
} break; |
case "stop": |
{// Stop button is clicked |
jQueryObject(clickedButton).removeClass(); |
jQueryObject(clickedButton).addClass("stopSelected"); |
// Find the start button. startButton is a jQuery object |
var startButton = findSiblingButtonByClassName(clickedButton, "startSelected"); |
if (startButton) {// Changes the image of the start button |
startButton.removeClass(); |
startButton.addClass("start"); |
} |
} break; |
} |
} |
// Finds a button by its className. Returns a jQuery object |
function findSiblingButtonByClassName(buttonInstance, className) { |
var jQuery = $telerik.$; |
var ulElement = jQuery(buttonInstance).parent().parent(); // get the UL element |
var allLiElements = jQuery("li", ulElement); // jQuery selector to find all LI elements |
for (var i = 0; i < allLiElements.length; i++) { |
var currentLi = allLiElements[i]; |
var currentAnchor = jQuery("A:first", currentLi); // Find the Anchor tag |
if (currentAnchor.hasClass(className)) { |
return currentAnchor; |
} |
} |
} |
ASPX
<telerik:RadRotator ID="rrNewToTheZoo" runat="server" Height="196px" Width="220px" |
Skin="Default" FrameDuration="700" ItemWidth="220px" RotatorType="FromCode" ScrollDirection="Up" |
DataSourceID="sdsNewToTheZoo"> |
<ItemTemplate> |
<table border="0" cellpadding="0" cellspacing="0" class="mini_profile_info"> |
<tr> |
<td> |
<a href="/people/profiles/?empno=<%# DataBinder.Eval(Container.DataItem, "pkEmployeeNumber")%>"> |
<%# DataBinder.Eval(Container.DataItem, "fullname")%></a> |
</td> |
</tr> |
<tr> |
<td> |
<%# DataBinder.Eval(Container.DataItem, "positionDescription")%> |
</td> |
</tr> |
<tr> |
<td style="padding-bottom: 10px;"> |
<%# DataBinder.Eval(Container.DataItem, "directorate")%> |
</td> |
</tr> |
</table> |
</ItemTemplate> |
</telerik:RadRotator> |
<div class="rotator_custom_up"> |
<a href="#" onmouseout="stopRotator(this, $find('<%= rrNewToTheZoo.ClientID %>')); return false;" |
onmouseover="startRotator(this, $find('<%= rrNewToTheZoo.ClientID %>'), Telerik.Web.UI.RotatorScrollDirection.Up); return false;"> |
<img src="/images/rotator_up_out.gif" width="9" height="6" alt="" /></a></div> |