-
Notifications
You must be signed in to change notification settings - Fork 0
Add files via upload #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
во втором нужно были на каждый блок делать отдельный div? и тогда координаты не со свойства space-around высчитываются? |
menu.style.top = `${event.clientY}px`; | ||
menu.style.left = `${event.clientX}px`; | ||
menu.classList.add("active"); | ||
if (`${event.clientX}` >= 1200) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У меня монитор 1920*1080. Поэтому меню исчезает уже при клике во второй половине экрана.
Необходимо было вычислять границу отрисовки в зависимости от размера области просмотра страницы и размеров самого меню.
menu.style.left = `${event.clientX}px`; | ||
menu.classList.add("active"); | ||
if (`${event.clientX}` >= 1200) { | ||
menu.style.cssText = "pading: 0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неверная запись свойства padding
В случае, если меню вылезает за границы страницы, его нужно лишь немного подвинуть так, чтобы оно было видно полностью на странице, а не рисовать в верхнем левом углу страницы. Для этого необходимо вычислить, на сколько пикселей меню заходит за экран и затем - отодвинуть его вверх или влево.
|
||
const menu3 = document.querySelector("#obj3"); | ||
|
||
menuArea.addEventListener( "contextmenu", event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем вешаете 4 обработчика на один и тот же контейнер ?
const menuArea = document.querySelector("#main"); | ||
const menu1 = document.querySelector("#obj1"); | ||
|
||
menuArea.addEventListener( "contextmenu", event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Должен обрабатываться обычный клик
width: 30px; | ||
height: 50px; | ||
background: purple; | ||
position : relative; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Позиционирование должно быть абсолютным
@@ -0,0 +1,127 @@ | |||
const menuArea = document.querySelector("#main"); | |||
const menu1 = document.querySelector("#obj1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У всех элементов одинаковая логика - можно было вешать обработчики делегированием
Y=ev.pageY; | ||
}); | ||
|
||
function move() { //зачем аргумент ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Движение должно начинаться только при клике на элемент
|
||
|
||
window.addEventListener('load', function () { //все в один блок, т.к. вам же надо получить #obj ? | ||
var O = document.getElementById('obj3'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Задавайте переменным осмысленные названия
в первом задании не понял как сделать так что бы при добавлении стилей относительно текущего указателя сдвигался блок,во втором не смог понять как сделать что бы блок не вылезал за пределы родителького и не стал продолжать делать клик и т.д