-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve Mouse Wheel * Code factor
- Loading branch information
Showing
5 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<style> | ||
body { | ||
min-height: 100vh; | ||
margin: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
div { | ||
width: 105px; | ||
height: 105px; | ||
background: #cdf; | ||
padding: 5px; | ||
} | ||
</style> | ||
<title>Element: wheel event - Scaling_an_element_via_the_wheel - code sample</title> | ||
</head> | ||
<body> | ||
<div>Scale me with your mouse wheel.</div> | ||
<script> | ||
function zoom(event) { | ||
event.preventDefault(); | ||
|
||
scale += event.deltaY * -0.01; | ||
|
||
// Restrict scale | ||
scale = Math.min(Math.max(.125, scale), 4); | ||
|
||
// Apply scale transform | ||
el.style.transform = `scale(${scale})`; | ||
} | ||
|
||
let scale = 1; | ||
const el = document.querySelector('div'); | ||
el.onwheel = zoom; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Runtime.Serialization; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace PuppeteerSharp.Input | ||
{ | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
internal enum PointerType | ||
{ | ||
[EnumMember(Value = "mouse")] | ||
Mouse, | ||
[EnumMember(Value = "pen")] | ||
Pen, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters