rege 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +24 -23
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/{types-dbd32c09.d.ts → types-372314b9.d.ts} +81 -66
- package/package.json +54 -28
- package/src/drag/index.ts +126 -0
- package/src/drag/react.ts +22 -0
- package/src/drag/types.ts +29 -0
- package/src/hover/index.ts +121 -0
- package/src/hover/react.ts +22 -0
- package/src/hover/types.ts +25 -0
- package/src/index.ts +7 -0
- package/src/key/index.ts +37 -0
- package/src/key/react.ts +20 -0
- package/src/key/types.ts +12 -0
- package/src/pinch/index.ts +447 -0
- package/src/pinch/react.ts +22 -0
- package/src/pinch/types.ts +63 -0
- package/src/pinch/utils.ts +106 -0
- package/src/react.ts +7 -0
- package/src/resize/index.ts +49 -0
- package/src/resize/react.ts +22 -0
- package/src/resize/types.ts +10 -0
- package/src/scroll/index.ts +101 -0
- package/src/scroll/react.ts +22 -0
- package/src/scroll/types.ts +29 -0
- package/src/scroll/utils.ts +7 -0
- package/src/utils.ts +109 -0
- package/src/wheel/index.ts +98 -0
- package/src/wheel/react.ts +22 -0
- package/src/wheel/types.ts +29 -0
- package/src/wheel/utils.ts +19 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { resizeEvent } from '.'
|
|
2
|
+
import { useMutable, useOnce } from 'reev/src/react'
|
|
3
|
+
import { ResizeArg, ResizeState } from './types'
|
|
4
|
+
import { isF } from '../utils'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
6
|
+
|
|
7
|
+
export const useResize = (arg: ResizeArg) => {
|
|
8
|
+
if (isF(arg)) arg = { resize: arg }
|
|
9
|
+
const memo = useMutable(arg)
|
|
10
|
+
return useOnce(() => resizeEvent(memo as any))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default useResize
|
|
14
|
+
|
|
15
|
+
export interface ResizeProps<El extends Element = Element> extends Partial<ResizeState<El>> {
|
|
16
|
+
children: (state: ResizeState<El>) => ReactNode
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Resize = <El extends Element = Element>(props: ResizeProps<El>) => {
|
|
20
|
+
const { children, ...other } = props
|
|
21
|
+
return children(useResize(other))
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ResizeState<El extends Element = Element> {
|
|
2
|
+
observer: ResizeObserver | null
|
|
3
|
+
listener(): void
|
|
4
|
+
mount(el: El): void
|
|
5
|
+
clean(el: null): void
|
|
6
|
+
resize(self: ResizeState<El>): void
|
|
7
|
+
ref(target: El): void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ResizeArg<El extends Element = Element> = Partial<ResizeState<El>> | ResizeState<El>['resize']
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { vec2, addV, cpV, subV } from '../utils'
|
|
2
|
+
import { scrollValues } from './utils'
|
|
3
|
+
import { EventState, event } from 'reev/src'
|
|
4
|
+
import { ScrollState } from './types'
|
|
5
|
+
|
|
6
|
+
export * from './types'
|
|
7
|
+
|
|
8
|
+
export const scrollEvent = <El extends Element = Element>(config?: ScrollState) => {
|
|
9
|
+
const initValues = () => {
|
|
10
|
+
vec2(0, 0, self.value)
|
|
11
|
+
vec2(0, 0, self._value)
|
|
12
|
+
vec2(0, 0, self.delta)
|
|
13
|
+
vec2(0, 0, self.movement)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const scroll = () => {
|
|
17
|
+
self.isScrollStart = self.active && !self._active
|
|
18
|
+
self.isScrolling = self.active && self._active
|
|
19
|
+
self.isScrollEnd = !self.active && self._active
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const scrollStart = (e: Event) => {
|
|
23
|
+
self.event = e
|
|
24
|
+
self.active = true
|
|
25
|
+
scrollValues(e, self.value)
|
|
26
|
+
self.scroll(self)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const scrolling = (e: Event) => {
|
|
30
|
+
// register wheelEnd
|
|
31
|
+
const id = setTimeout(() => self.scrollEnd(e), self.timeout)
|
|
32
|
+
self.clearTimeout()
|
|
33
|
+
self.clearTimeout = () => clearTimeout(id)
|
|
34
|
+
|
|
35
|
+
if (!self.active) {
|
|
36
|
+
self.scrollStart(e)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
self.event = e
|
|
41
|
+
self._active = self.active
|
|
42
|
+
cpV(self.value, self._value)
|
|
43
|
+
scrollValues(e, self.value)
|
|
44
|
+
if (self._active) {
|
|
45
|
+
subV(self.value, self._value, self.delta)
|
|
46
|
+
addV(self.offset, self.delta, self.offset)
|
|
47
|
+
addV(self.movement, self.delta, self.movement)
|
|
48
|
+
}
|
|
49
|
+
self.scroll(self)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const scrollEnd = (e: Event) => {
|
|
53
|
+
self.event = e
|
|
54
|
+
self.active = false
|
|
55
|
+
initValues()
|
|
56
|
+
self.scroll(self)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const mount = (target: El) => {
|
|
60
|
+
self.target = target // @TODO set event to target
|
|
61
|
+
window.addEventListener('scroll', self.scrolling)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const clean = () => {
|
|
65
|
+
window.removeEventListener('scroll', self.scrolling)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const ref = (el: Element | null) => {
|
|
69
|
+
self(config as ScrollState<El>)
|
|
70
|
+
if (el) {
|
|
71
|
+
self.mount(el)
|
|
72
|
+
} else self.clean(null)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const self = event({
|
|
76
|
+
active: false,
|
|
77
|
+
_active: false,
|
|
78
|
+
_value: vec2(0, 0),
|
|
79
|
+
value: vec2(0, 0),
|
|
80
|
+
delta: vec2(0, 0),
|
|
81
|
+
offset: vec2(0, 0),
|
|
82
|
+
movement: vec2(0, 0),
|
|
83
|
+
target: null,
|
|
84
|
+
event: null,
|
|
85
|
+
memo: {},
|
|
86
|
+
timeout: 100,
|
|
87
|
+
clearTimeout: () => {},
|
|
88
|
+
isScrollStart: false,
|
|
89
|
+
isScrolling: false,
|
|
90
|
+
isScrollEnd: false,
|
|
91
|
+
scroll,
|
|
92
|
+
scrollStart,
|
|
93
|
+
scrolling,
|
|
94
|
+
scrollEnd,
|
|
95
|
+
mount,
|
|
96
|
+
clean,
|
|
97
|
+
ref,
|
|
98
|
+
}) as EventState<ScrollState<El>>
|
|
99
|
+
|
|
100
|
+
return self
|
|
101
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useOnce, useMutable } from 'reev/src/react'
|
|
2
|
+
import { ScrollConfig, ScrollState } from './types'
|
|
3
|
+
import { scrollEvent } from './index'
|
|
4
|
+
import { isF } from '../utils'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
6
|
+
|
|
7
|
+
export const useScroll = <El extends Element = Element>(config: ScrollConfig) => {
|
|
8
|
+
if (isF(config)) config = { scroll: config }
|
|
9
|
+
const memo = useMutable(config)
|
|
10
|
+
return useOnce(() => scrollEvent<El>(memo as any))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default useScroll
|
|
14
|
+
|
|
15
|
+
export interface ScrollProps<El extends Element = Element> extends Partial<ScrollState<El>> {
|
|
16
|
+
children: (state: ScrollState<El>) => ReactNode
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Scroll = <El extends Element = Element>(props: ScrollProps<El>) => {
|
|
20
|
+
const { children, ...other } = props
|
|
21
|
+
return children(useScroll(other))
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Vec2 } from '../utils'
|
|
2
|
+
|
|
3
|
+
export interface ScrollState<El extends Element = Element> {
|
|
4
|
+
_active: boolean
|
|
5
|
+
active: boolean
|
|
6
|
+
_value: Vec2
|
|
7
|
+
value: Vec2
|
|
8
|
+
delta: Vec2
|
|
9
|
+
offset: Vec2
|
|
10
|
+
movement: Vec2
|
|
11
|
+
target: El
|
|
12
|
+
event: Event
|
|
13
|
+
memo: any
|
|
14
|
+
isScrollStart: boolean
|
|
15
|
+
isScrolling: boolean
|
|
16
|
+
isScrollEnd: boolean
|
|
17
|
+
timeout: number
|
|
18
|
+
clearTimeout(): void
|
|
19
|
+
scroll(self: ScrollState<El>): void
|
|
20
|
+
scrollStart(e: Event): void
|
|
21
|
+
scrolling(e: Event): void
|
|
22
|
+
scrollEnd(e: Event): void
|
|
23
|
+
mount(target: Element): void
|
|
24
|
+
clean(target: null): void
|
|
25
|
+
ref(traget: Element): void
|
|
26
|
+
tick?: () => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ScrollConfig<El extends Element = Element> = Partial<ScrollState<El>> | ScrollState<El>['scroll']
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CALCULATE VECTOR
|
|
3
|
+
* REF: https://github.com/toji/gl-matrix/blob/master/src/vec2.js
|
|
4
|
+
*/
|
|
5
|
+
export const isF = (f: unknown): f is Function => typeof f === 'function'
|
|
6
|
+
|
|
7
|
+
const Vec = typeof Float32Array !== 'undefined' ? Float32Array : Array
|
|
8
|
+
|
|
9
|
+
export const vec2 = (x = 0, y = 0, out = new Vec(2)): Vec2 => {
|
|
10
|
+
out[0] = x
|
|
11
|
+
out[1] = y
|
|
12
|
+
return out as Vec2
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Vec2 = [x: number, y: number]
|
|
16
|
+
|
|
17
|
+
export const addV = (a: Vec2, b: Vec2, out = vec2()): Vec2 => {
|
|
18
|
+
out[0] = a[0] + b[0]
|
|
19
|
+
out[1] = a[1] + b[1]
|
|
20
|
+
return out
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const subV = (a: Vec2, b: Vec2, out = vec2()): Vec2 => {
|
|
24
|
+
out[0] = a[0] - b[0]
|
|
25
|
+
out[1] = a[1] - b[1]
|
|
26
|
+
return out
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const cpV = (a: Vec2, out = vec2()): Vec2 => {
|
|
30
|
+
out[0] = a[0]
|
|
31
|
+
out[1] = a[1]
|
|
32
|
+
return out
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* SUPPORT
|
|
37
|
+
*/
|
|
38
|
+
const isBrowser = typeof window !== 'undefined' && !!window.document && !!window.document.createElement
|
|
39
|
+
|
|
40
|
+
const supportsTouchEvents = () => isBrowser && 'ontouchstart' in window
|
|
41
|
+
|
|
42
|
+
const isTouchScreen = () => supportsTouchEvents() || (isBrowser && window.navigator.maxTouchPoints > 1)
|
|
43
|
+
|
|
44
|
+
const supportsPointerEvents = () => isBrowser && 'onpointerdown' in window
|
|
45
|
+
|
|
46
|
+
const supportsPointerLock = () => isBrowser && 'exitPointerLock' in window.document
|
|
47
|
+
|
|
48
|
+
const supportsGestureEvents = () => {
|
|
49
|
+
try {
|
|
50
|
+
// @ts-ignore eslint-disable-next-line
|
|
51
|
+
return 'constructor' in GestureEvent
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// prettier-ignore
|
|
58
|
+
export const SUPPORT: Record<string, boolean> = { // Mac
|
|
59
|
+
isBrowser, // true
|
|
60
|
+
get gesture() {
|
|
61
|
+
return (
|
|
62
|
+
SUPPORT._gesture ??
|
|
63
|
+
(SUPPORT._gesture = supportsGestureEvents())
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
get touch() {
|
|
67
|
+
return (
|
|
68
|
+
SUPPORT._touch ??
|
|
69
|
+
(SUPPORT._touch = supportsTouchEvents())
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
get touchscreen() {
|
|
73
|
+
return (
|
|
74
|
+
SUPPORT._touchscreen ??
|
|
75
|
+
(SUPPORT._touchscreen = isTouchScreen())
|
|
76
|
+
)
|
|
77
|
+
},
|
|
78
|
+
get pointer() {
|
|
79
|
+
return (
|
|
80
|
+
SUPPORT._pointer ??
|
|
81
|
+
(SUPPORT._pointer = supportsPointerEvents())
|
|
82
|
+
)
|
|
83
|
+
},
|
|
84
|
+
get pointerLock() {
|
|
85
|
+
return (
|
|
86
|
+
SUPPORT._pointerLock ??
|
|
87
|
+
(SUPPORT._pointerLock = supportsPointerLock())
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* https://github.com/pmndrs/use-gesture/blob/main/packages/core/src/config/dragConfigResolver.ts
|
|
94
|
+
*/
|
|
95
|
+
export const getDevice = (lock = false) => {
|
|
96
|
+
const pointerLock = lock && SUPPORT.pointerLock
|
|
97
|
+
if (pointerLock) return 'mouse'
|
|
98
|
+
if (SUPPORT.touch) return 'touch'
|
|
99
|
+
if (SUPPORT.pointer) return 'pointer'
|
|
100
|
+
return 'mouse'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const getClientVec2 = (e: any, device: unknown, out: Vec2): Vec2 => {
|
|
104
|
+
if (device !== 'touch') {
|
|
105
|
+
return vec2(e.clientX, e.clientY, out)
|
|
106
|
+
}
|
|
107
|
+
const [touch] = e.changedTouches
|
|
108
|
+
return vec2(touch.clientX, touch.clientY, out)
|
|
109
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { vec2, addV, cpV } from '../utils'
|
|
2
|
+
import { wheelValues } from './utils'
|
|
3
|
+
import { EventState, event } from 'reev/src'
|
|
4
|
+
import { WheelState } from './types'
|
|
5
|
+
|
|
6
|
+
export * from './types'
|
|
7
|
+
|
|
8
|
+
export const wheelEvent = <El extends Element = Element>(config?: WheelState) => {
|
|
9
|
+
const initValues = () => {
|
|
10
|
+
vec2(0, 0, self.value)
|
|
11
|
+
vec2(0, 0, self._value)
|
|
12
|
+
vec2(0, 0, self.delta)
|
|
13
|
+
vec2(0, 0, self.movement)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const wheel = () => {
|
|
17
|
+
self.isWheelStart = self.active && !self._active
|
|
18
|
+
self.isWheeling = self.active && self._active
|
|
19
|
+
self.isWheelEnd = !self.active && self._active
|
|
20
|
+
}
|
|
21
|
+
const wheelStart = (e: WheelEvent) => {
|
|
22
|
+
self.event = e
|
|
23
|
+
self.active = true
|
|
24
|
+
wheelValues(e, self.delta)
|
|
25
|
+
self.wheel(self)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const wheeling = (e: Event) => {
|
|
29
|
+
// register wheelEnd
|
|
30
|
+
const id = setTimeout(() => self.wheelEnd(e), self.timeout)
|
|
31
|
+
self.clearTimeout()
|
|
32
|
+
self.clearTimeout = () => clearTimeout(id)
|
|
33
|
+
self.event = e
|
|
34
|
+
if (!self.active) {
|
|
35
|
+
self.wheelStart(e)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
self._active = self.active
|
|
40
|
+
cpV(self.value, self._value)
|
|
41
|
+
wheelValues(e, self.delta)
|
|
42
|
+
addV(self.offset, self.delta, self.offset)
|
|
43
|
+
addV(self.movement, self.delta, self.movement)
|
|
44
|
+
self.wheel(self)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const wheelEnd = (e: Event) => {
|
|
48
|
+
self.event = e
|
|
49
|
+
self.active = false
|
|
50
|
+
initValues()
|
|
51
|
+
self.wheel(self)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const mount = (target: El) => {
|
|
55
|
+
self.target = target
|
|
56
|
+
target.addEventListener('wheel', self.wheeling)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const clean = () => {
|
|
60
|
+
const target = self.target
|
|
61
|
+
if (!target) return
|
|
62
|
+
target.removeEventListener('wheel', self.wheeling)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ref = (el: Element | null) => {
|
|
66
|
+
self(config as WheelState<El>)
|
|
67
|
+
if (el) {
|
|
68
|
+
self.mount(el)
|
|
69
|
+
} else self.clean(null)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const self = event({
|
|
73
|
+
active: false,
|
|
74
|
+
_active: false,
|
|
75
|
+
_value: vec2(0, 0),
|
|
76
|
+
value: vec2(0, 0),
|
|
77
|
+
delta: vec2(0, 0),
|
|
78
|
+
offset: vec2(0, 0),
|
|
79
|
+
movement: vec2(0, 0),
|
|
80
|
+
target: null,
|
|
81
|
+
event: null,
|
|
82
|
+
timeout: 100,
|
|
83
|
+
clearTimeout: () => {},
|
|
84
|
+
memo: {},
|
|
85
|
+
isWheelStart: false,
|
|
86
|
+
isWheeling: false,
|
|
87
|
+
isWheelEnd: false,
|
|
88
|
+
wheel,
|
|
89
|
+
wheelStart,
|
|
90
|
+
wheeling,
|
|
91
|
+
wheelEnd,
|
|
92
|
+
mount,
|
|
93
|
+
clean,
|
|
94
|
+
ref,
|
|
95
|
+
}) as EventState<WheelState<El>>
|
|
96
|
+
|
|
97
|
+
return self
|
|
98
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useOnce, useMutable } from 'reev/src/react'
|
|
2
|
+
import { WheelConfig, WheelState } from './types'
|
|
3
|
+
import { wheelEvent } from './index'
|
|
4
|
+
import { isF } from '../utils'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
6
|
+
|
|
7
|
+
export const useWheel = <El extends Element = Element>(config: WheelConfig) => {
|
|
8
|
+
if (isF(config)) config = { wheel: config }
|
|
9
|
+
const memo = useMutable(config)
|
|
10
|
+
return useOnce(() => wheelEvent<El>(memo as any))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default useWheel
|
|
14
|
+
|
|
15
|
+
export interface WheelProps<El extends Element = Element> extends Partial<WheelState<El>> {
|
|
16
|
+
children: (state: WheelState<El>) => ReactNode
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Wheel = <El extends Element = Element>(props: WheelProps<El>) => {
|
|
20
|
+
const { children, ...other } = props
|
|
21
|
+
return children(useWheel(other))
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Vec2 } from '../utils'
|
|
2
|
+
|
|
3
|
+
export interface WheelState<El extends Element = Element> {
|
|
4
|
+
_active: boolean
|
|
5
|
+
active: boolean
|
|
6
|
+
_value: Vec2
|
|
7
|
+
value: Vec2
|
|
8
|
+
delta: Vec2
|
|
9
|
+
offset: Vec2
|
|
10
|
+
movement: Vec2
|
|
11
|
+
target: El
|
|
12
|
+
event: Event
|
|
13
|
+
timeout: number
|
|
14
|
+
clearTimeout(): void
|
|
15
|
+
memo: any
|
|
16
|
+
isWheelStart: boolean
|
|
17
|
+
isWheeling: boolean
|
|
18
|
+
isWheelEnd: boolean
|
|
19
|
+
wheel(self: WheelState<El>): void
|
|
20
|
+
wheelStart(e: Event): void
|
|
21
|
+
wheeling(e: Event): void
|
|
22
|
+
wheelEnd(e: Event): void
|
|
23
|
+
mount(target: Element): void
|
|
24
|
+
clean(target: null): void
|
|
25
|
+
ref(traget: Element | null): void
|
|
26
|
+
tick?: () => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type WheelConfig<El extends Element = Element> = Partial<WheelState<El>> | WheelState<El>['wheel']
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { vec2, Vec2 } from '../utils'
|
|
2
|
+
|
|
3
|
+
const LINE_HEIGHT = 40
|
|
4
|
+
|
|
5
|
+
const PAGE_HEIGHT = 800
|
|
6
|
+
|
|
7
|
+
export const wheelValues = (event: Event, out: Vec2): Vec2 => {
|
|
8
|
+
if (!(event instanceof WheelEvent)) return vec2(0, 0, out)
|
|
9
|
+
|
|
10
|
+
let { deltaX, deltaY, deltaMode } = event
|
|
11
|
+
if (deltaMode === 1) {
|
|
12
|
+
deltaX *= LINE_HEIGHT
|
|
13
|
+
deltaY *= LINE_HEIGHT
|
|
14
|
+
} else if (deltaMode === 2) {
|
|
15
|
+
deltaX *= PAGE_HEIGHT
|
|
16
|
+
deltaY *= PAGE_HEIGHT
|
|
17
|
+
}
|
|
18
|
+
return vec2(deltaX, deltaY, out)
|
|
19
|
+
}
|