← Winnitude! Search  ·  Reader Mode (3092 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 33 LINKS

Translate 'Drag'n'Drop with mouse events' article to Portuguese by diogoosz · Pull Request #517 · javascript-tutorial/pt.javascript.info

Repository navigation

Translate 'Drag'n'Drop with mouse events' article to Portuguese - #517


Open
diogoosz wants to merge 1 commit into javascript-tutorial:master from diogoosz:translate-mouse-drag-and-drop
Open

Translate 'Drag'n'Drop with mouse events' article to Portuguese #517 diogoosz wants to merge 1 commit into javascript-tutorial:master from diogoosz:translate-mouse-drag-and-drop

Conversation

diogoosz commented Nov 23, 2026



Copy link Copy Markdown
Contributor

Resumo

Conforme comentado na #1 .

  • Traduz article.md por completo (algoritmo de drag'n'drop, posicionamento correto com shiftX/shiftY, detecção de droppables via document.elementFromPoint).
  • Traduz os dois exercícios: 1-slider (task.md, solution.md, comentários em solution.view/index.html, placeholder em source.view) e 2-drag-heroes (task.md, solution.md, texto narrativo e comentários em soccer.js/soccer.css nas duas views).
  • Traduz o texto narrativo e os comentários de código nas demos ball.view, ball2.view, ball3.view e ball4.view.
  • Nenhum SVG deste capítulo precisou de tradução: os rótulos em ball_shift.svg (shiftX, shiftY) e field.svg ((0,0), clientWidth) são identificadores de código já referenciados pelo nome original no texto do artigo/exercício, então images.yml não foi alterado.

Plano de teste

  • git diff --stat upstream/master -- '*.svg' vazio (nenhum SVG tocado).
  • Diff de code spans (crases) entre o original e a tradução para article.md e os task.md/solution.md dos dois exercícios -- sem perdas, contagem de crases idêntica em todos.
  • Grep de registro/falsos cognatos (pra/pro/tipo/atualmente/cobrir etc.) -- nenhum hit.
  • Títulos de article.md e dos dois task.md confirmados traduzidos (mantive "Slider" como título, já que o termo é usado como anglicismo aceito ao longo do próprio texto, ex: "o slider é uma <div>...").
Translate 'Drag'n'Drop with mouse events' article to Portuguese a2dc03e
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
diogoosz mentioned this pull request Nov 23, 2026 Translate 'Pointer events' article to Portuguese #518 Merged 4 tasks done gabifs reviewed Dec 6, 2026
View reviewed changes

gabifs left a comment



Copy link Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more .

Obrigado pela tradução, @diogoosz ! Ficou muito boa: fiel ao original e com o código e os marcadores preservados. Deixei alguns comentários abaixo; os marcados como Importante valem corrigir antes do merge, os demais são opcionais.

Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/1-slider/task.md
@@ -4,13 +4,13 @@ importance: 5

# Slider
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/1-slider/task.md
# Slider

Create a slider:
Crie um slider:
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/1-slider/task.md
[iframe src="solution" height=60 border=1]

Drag the blue thumb with the mouse and move it .
Arraste o controle deslizante azul com o mouse e mova-o .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/1-slider/solution.md
@@ -1,5 +1,5 @@
As we can see from HTML/CSS, the slider is a `<div>` with a colored background, that contains a runner -- another `<div>` with `position:relative`.
Como podemos ver pelo HTML/CSS, o slider é uma `<div>` com um fundo colorido, que contém um controle deslizante -- outra `<div>` com `position:relative`.
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/1-slider/task.md
- When the mouse button is pressed, during the dragging the mouse may go over or below the slider. The slider will still work (convenient for the user ).
- If the mouse moves very fast to the left or to the right, the thumb should stop exactly at the edge .
- Quando o botão do mouse é pressionado, durante o arrasto o mouse pode ir para cima ou para baixo do slider. O slider ainda vai funcionar (conveniente para o usuário ).
- Se o mouse se move muito rápido para a esquerda ou para a direita, o controle deve parar exatamente na borda .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/article.md
Vamos atualizar nosso algoritmo :

1. When a visitor presses the button (`mousedown`) - remember the distance from the pointer to the left-upper corner of the ball in variables `shiftX/shiftY`. We'll keep that distance while dragging .
1. Quando um visitante pressiona o botão (`mousedown`) - lembre a distância do cursor até o canto superior esquerdo da bola nas variáveis `shiftX/shiftY`. Vamos manter essa distância durante o arrasto .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/article.md
2. At the drag start -- remember the initial shift of the pointer relative to the element : `shiftX/shiftY` and keep it during the dragging .
3. Detect droppable elements under the pointer using `document.elementFromPoint`.
1. Fluxo de eventos : `ball.mousedown` -> `document.mousemove` -> `ball.mouseup` ( não se esqueça de cancelar o `ondragstart` nativo ).
2. No início do arrasto -- lembre o deslocamento inicial do cursor em relação ao elemento : `shiftX/shiftY` e mantenha-o durante o arrasto .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/article.md
- e, de preferência, saber sobre qual soltável estamos arrastando, para destacá-lo .

The solution is kind-of interesting and just a little bit tricky, so let's cover it here .
A solução é meio interessante e só um pouco complicada, então vamos cobri-la aqui .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/article.md
```

The same with a draggable element. The ball is always on top over other elements, so events happen on it. Whatever handlers we set on lower elements, they won't work .
O mesmo com um elemento arrastável. A bola está sempre no topo sobre os outros elementos, então os eventos acontecem nela. Quaisquer manipuladores que definirmos nos elementos inferiores, eles não vão funcionar .
Comment thread 2-ui/3-event-details/4-mouse-drag-and-drop/article.md
## Algoritmo de Drag'n'Drop

The basic Drag'n'Drop algorithm looks like this :
O algoritmo básico de Drag'n'Drop parece assim :
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants