Scroll to End

XanMag

JS(ScrollToEnd) used to work just fine, but I can't seem to get it right now. After every turn, how do you scroll to the bottom of the page after a typed response?

Thanks!


Alexandre Torres

A hot fix to the scroll problem. Create a javascript file at the same dir, add it to your game. Add this code inside:

function scrollToEnd() {
    var scrollTo = _animateScroll ? beginningOfCurrentTurnScrollPosition - 50 - $("#gamePanelSpacer").height() : $(document).height();
    var currentScrollTop = Math.max($("body").scrollTop(), $("html").scrollTop());
    if (scrollTo > currentScrollTop) {
        var maxScrollTop = $(document).height() - $(window).height();
        if (scrollTo > maxScrollTop) scrollTo = maxScrollTop;
        var distance = scrollTo - currentScrollTop;
        var duration = _animateScroll ? distance / 0.4 : 1;
        if (duration>2000)
            duration=2000
        $("body,html").stop().animate({ scrollTop: scrollTo }, duration, "easeInOutCubic");
    }
    $("#txtCommand").focus();
}

The problem here is that the duration grows without limits, so you just have to put a limit (2000 is 2 seconds) in the time to scroll the entire game-page. I'm not sure if this is the problem you are facing, if not just ignore :)


Log in to post a reply.

Support

Forums