Merge pull request #2971 from Rnbsov/side-effect
replace side-effect with side effect
This commit is contained in:
commit
87b5780c79
10 changed files with 10 additions and 10 deletions
|
@ -154,7 +154,7 @@ Move the mouse over the input field to see `clientX/clientY` (the example is in
|
|||
|
||||
## Preventing selection on mousedown
|
||||
|
||||
Double mouse click has a side-effect that may be disturbing in some interfaces: it selects text.
|
||||
Double mouse click has a side effect that may be disturbing in some interfaces: it selects text.
|
||||
|
||||
For instance, double-clicking on the text below selects it in addition to our handler:
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ ball.style.left = pageX - ball.offsetWidth / 2 + 'px';
|
|||
ball.style.top = pageY - ball.offsetHeight / 2 + 'px';
|
||||
```
|
||||
|
||||
Not bad, but there's a side-effect. To initiate the drag'n'drop, we can `mousedown` anywhere on the ball. But if "take" it from its edge, then the ball suddenly "jumps" to become centered under the mouse pointer.
|
||||
Not bad, but there's a side effect. To initiate the drag'n'drop, we can `mousedown` anywhere on the ball. But if "take" it from its edge, then the ball suddenly "jumps" to become centered under the mouse pointer.
|
||||
|
||||
It would be better if we keep the initial shift of the element relative to the pointer.
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ The `onkeydown` handler here uses `checkPhoneKey` to check for the key pressed.
|
|||
|
||||
As we know, the `false` value returned from the event handler, assigned using a DOM property or an attribute, such as above, prevents the default action, so nothing appears in the `<input>` for keys that don't pass the test. (The `true` value returned doesn't affect anything, only returning `false` matters)
|
||||
|
||||
Please note that special keys, such as `key:Backspace`, `key:Left`, `key:Right`, do not work in the input. That's a side-effect of the strict filter `checkPhoneKey`. These keys make it return `false`.
|
||||
Please note that special keys, such as `key:Backspace`, `key:Left`, `key:Right`, do not work in the input. That's a side effect of the strict filter `checkPhoneKey`. These keys make it return `false`.
|
||||
|
||||
Let's relax the filter a little bit by allowing arrow keys `key:Left`, `key:Right` and `key:Delete`, `key:Backspace`:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue