File tree Expand file tree Collapse file tree
2-ui/2-events-and-interfaces/1-introduction-browser-events/6-carousel/solution.view Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050 var position = 0 ; // текущий сдвиг влево
5151
5252 carousel . querySelector ( '.prev' ) . onclick = function ( ) {
53- if ( position >= 0 ) return ; // уже сдвинулись до упора
54-
5553 // сдвиг влево
5654 // последнее передвижение влево может быть не на 3, а на 2 или 1 элемент
5755 position = Math . min ( position + width * count , 0 )
5856 list . style . marginLeft = position + 'px' ;
5957 } ;
6058
6159 carousel . querySelector ( '.next' ) . onclick = function ( ) {
62- if ( position <= - width * ( listElems . length - count ) ) return ; // уже до упора
63-
6460 // сдвиг вправо
6561 // последнее передвижение вправо может быть не на 3, а на 2 или 1 элемент
6662 position = Math . max ( position - width * count , - width * ( listElems . length - count ) ) ;
You can’t perform that action at this time.
0 commit comments