Skip to content

Commit eabc573

Browse files
authored
Resolve conflicts
1 parent 2700304 commit eabc573

File tree

1 file changed

+0
-49
lines changed
  • 2-ui/3-event-details/1-mouse-events-basics

1 file changed

+0
-49
lines changed

2-ui/3-event-details/1-mouse-events-basics/article.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,9 @@ For JS-code it means that we should check `if (event.ctrlKey || event.metaKey)`.
124124
```
125125
126126
```warn header="There are also mobile devices"
127-
<<<<<<< HEAD
128-
Keyboard combinations are good as an addition to the workflow. So that if the visitor has a
129-
keyboard -- it works. And if your device doesn't have it -- then there's another way to do the same.
130-
=======
131127
Keyboard combinations are good as an addition to the workflow. So that if the visitor uses a keyboard -- they work.
132128
133129
But if their device doesn't have it -- then there should be a way to live without modifier keys.
134-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
135130
```
136131

137132
## Coordinates: clientX/Y, pageX/Y
@@ -141,17 +136,13 @@ All mouse events provide coordinates in two flavours:
141136
1. Window-relative: `clientX` and `clientY`.
142137
2. Document-relative: `pageX` and `pageY`.
143138

144-
<<<<<<< HEAD
145-
For instance, if we have a window of the size 500x500, and the mouse is in the left-upper corner, then `clientX` and `clientY` are `0`. And if the mouse is in the center, then `clientX` and `clientY` are `250`, no matter what place in the document it is. They are similar to `position:fixed`.
146-
=======
147139
We already covered the difference between them in the chapter <info:coordinates>.
148140

149141
In short, document-relative coordinates `pageX/Y` are counted from the left-upper corner of the document, and do not change when the page is scrolled, while `clientX/Y` are counted from the current window left-upper corner. When the page is scrolled, they change.
150142

151143
For instance, if we have a window of the size 500x500, and the mouse is in the left-upper corner, then `clientX` and `clientY` are `0`, no matter how the page is scrolled.
152144

153145
And if the mouse is in the center, then `clientX` and `clientY` are `250`, no matter what place in the document it is. They are similar to `position:fixed` in that aspect.
154-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
155146

156147
````online
157148
Move the mouse over the input field to see `clientX/clientY` (the example is in the `iframe`, so coordinates are relative to that `iframe`):
@@ -163,19 +154,7 @@ Move the mouse over the input field to see `clientX/clientY` (the example is in
163154

164155
## Preventing selection on mousedown
165156

166-
<<<<<<< HEAD
167-
<<<<<<< HEAD
168-
## No selection on mousedown
169-
170-
Mouse clicks have a side-effect that may be disturbing. A double click selects the text.
171-
172-
If we want to handle click events ourselves, then the "extra" selection doesn't look good.
173-
=======
174-
Double mouse click has a side-effect that may be disturbing in some interfaces: it selects the text.
175-
>>>>>>> 852ee189170d9022f67ab6d387aeae76810b5923
176-
=======
177157
Double mouse click has a side-effect that may be disturbing in some interfaces: it selects text.
178-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
179158

180159
For instance, double-clicking on the text below selects it in addition to our handler:
181160

@@ -197,26 +176,7 @@ Before...
197176
...After
198177
```
199178

200-
<<<<<<< HEAD
201-
Now the bold element is not selected on double clicks.
202-
203-
The text inside it is still selectable. However, the selection should start not on the text itself, but before or after it. Usually that's fine though.
204-
205-
````smart header="Canceling the selection"
206-
Instead of *preventing* the selection, we can cancel it "post-factum" in the event handler.
207-
208-
Here's how:
209-
210-
```html autorun height=50
211-
Before...
212-
<b ondblclick="*!*getSelection().removeAllRanges()*/!*">
213-
Double-click me
214-
</b>
215-
...After
216-
```
217-
=======
218179
Now the bold element is not selected on double clicks, and pressing the left button on it won't start the selection.
219-
>>>>>>> 852ee189170d9022f67ab6d387aeae76810b5923
220180

221181
Please note: the text inside it is still selectable. However, the selection should start not on the text itself, but before or after it. Usually that's fine for users.
222182

@@ -246,15 +206,6 @@ Mouse events have the following properties:
246206
- Window-relative coordinates: `clientX/clientY`.
247207
- Document-relative coordinates: `pageX/pageY`.
248208

249-
<<<<<<< HEAD
250-
It's also important to deal with text selection as an unwanted side-effect of clicks.
251-
252-
There are several ways to do this, for instance:
253-
1. The CSS-property `user-select:none` (with browser prefixes) completely disables text-selection.
254-
2. Cancel the selection post-factum using `getSelection().removeAllRanges()`.
255-
3. Handle `mousedown` and prevent the default action (usually the best).
256-
=======
257209
The default browser action of `mousedown` is text selection, if it's not good for the interface, then it should be prevented.
258210

259211
In the next chapter we'll see more details about events that follow pointer movement and how to track element changes under it.
260-
>>>>>>> 852ee189170d9022f67ab6d387aeae76810b5923

0 commit comments

Comments
 (0)