deltaMode
The JavaScript deltaMode property returns a number that represents the unit of the shift values.
- 0 = pixels
- 1 = lines
- 2 = pages
Syntax:
var deltaMode = event.deltaMode
- This property is read-only.
Example
<body onwheel="deltaFunction(event)">
<p id="result"></p>
<p><strong>Note:</strong> 0 = pixels, 1 = lines, 2 = pages.</p>
<script>
function deltaFunction(event) {
var dlt = event.deltaMode;
document.getElementById("result").innerHTML = dlt;
}
</script>
</body>
deltaX
The JavaScript deltaX property returns numbers that are scrolled to the right and left. Moving to the right takes positive values. If we slide to the left, it takes negative values. Returns 0 if no scrolls.
Notes:
- Most mouse devices do not have the ability to scroll left and right and always return 0.
- This property is read-only.
Syntax:
var deltaX = event.deltaX;
- This property is read-only.
Example
<body onwheel="deltaFunction(event)">
<h2>deltaX</h2>
<p id="result"></p>
<p><strong>Note:</strong> 0 = pixels, 1 = lines, 2 = pages.</p>
<script>
function deltaFunction(event) {
var dlt = event.deltaX;
document.getElementById("result").innerHTML = dlt;
}
</script>
</body>
deltaY
The JavaScript deltaY property returns numbers that are scrolled up and down. Gets negative values when scrolling upwards. Gets positive values slid down. Returns 0 as the default value if it is not wrapped.
Syntax:
var deltaY = event.deltaY;
- This property is read-only.
Example
<body onwheel="deltaFunction(event)">
<h2>deltaY</h2>
<p id="result"></p>
<p><strong>Note:</strong> 0 = pixels, 1 = lines, 2 = pages.</p>
<script>
function deltaFunction(event) {
var dlt = event.deltaY;
document.getElementById("result").innerHTML = dlt;
}
</script>
</body>
Leave a comment