Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   Анимированое меню. Проблема (https://javascript.ru/forum/dom-window/13466-animirovanoe-menyu-problema.html)

Maximor17 29.11.2010 20:38

Анимированое меню. Проблема
 
Вот код:
// Change text position of menu bar

with ( textMoveRevers = new Function ) {
    prototype.add = 5;
    
    prototype.padStartLtoR = 0;
    prototype.widthStartToR = 202;
    
    prototype.padStartRtoL = 61;
    prototype.widthStartToL = 141;
    
    prototype.getElement = function() {
        for ( this.n = 1; this.n < 6; this.n ++ ) {
            this.elemId = "navRow" + this.n;
            this.elem = document.getElementById(this.elemId);
            
            with (this.elem) {
                setAttribute("onmouseover", "actionMenu.moveRight(this)");
                setAttribute("onmouseout", "actionMenu.moveLeft(this)");
            }
        }
    }
    
    prototype.moveRight = function( elem ) {
        this.row = document.getElementById(elem.id);
        if ( this.row.className != "menu_active_row" ) {
            this.moveRightStart(1);
        }
    }
    
    prototype.moveRightStart = function( count ) {
        this.counter = count;
        if ( this.counter < 60 ) {
            with ( this.row.style ) {
                paddingLeft = (this.padStartLtoR + this.counter);
                width = (this.widthStartToR - this.counter);
            }
            setTimeout("actionMenu.moveRightStart(" + (this.counter + this.add) + ")", 1);
        }
    }
    
    prototype.moveLeft = function( elem ) {
        this.row = document.getElementById(elem.id);
        if ( this.row.className != "menu_active_row" ) {
            this.moveLeftStart(1);
        }
    }
    
    prototype.moveLeftStart = function( count ) {
        this.counter = count;
        if ( this.counter < 60 ) {
            with ( this.row.style ) {
                paddingLeft = (this.padStartRtoL - this.counter);
                width = (this.widthStartToL + this.counter);
            }
            setTimeout("actionMenu.moveLeftStart(" + (this.counter + this.add) + ")", 1);
        }
    }
}

actionMenu = new textMoveRevers;

window.onload = actionMenu.getElement; // Определяет обработчики события для правого меню

Вот сайт: http://greenl.info
Левая панель навигации работает не так как надо. Как я понял - при скором наведении курсора на элемент, объекту передается именно этот элемент, и получается так что ранее активный элемент замирает "не доехав" до конца.
Как решить проблему? Заранее благодарен

dmitriymar 30.11.2010 08:05

а мож для начала сделать так чтобы сайт во всех браузерах работал?

Maximor17 30.11.2010 10:25

Критика не уместна. Но все же... кроссбраузерность не так интересна, как js, поэтому проблемы в соответствующем приоритете. Сайт неработоспособен в ИЕ, спору нет, но просьбы о помощи в коде это не отменяло.

Snipe 30.11.2010 10:35

Что-то мне сложно вчитаться. У вас один объект на разные кнопки?
А зачем тогда прототипы? Если у вас один объект.

Если бы на каждую кнопку по объекту - тогда бы я понял такие ухищрения.
Это как бы совет и есть. Делайте на каждую кнопку отдельный объект. Все эти объекты могут наследоваться от общего. Тогда и прототипы будут уместны.

Maximor17 12.12.2010 16:38

Спасибо. Так и сделал


Часовой пояс GMT +3, время: 21:54.