MCPcopy
hub / github.com/BoxFactura/pulltorefresh.js / _onTouchMove

Function _onTouchMove

src/lib/events.js:35–90  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

33 }
34
35 function _onTouchMove(e) {
36 if (!(_el && _el.ptrElement && _shared.enable)) {
37 return;
38 }
39
40 if (!_shared.pullStartY) {
41 if (_el.shouldPullToRefresh()) {
42 _shared.pullStartY = screenY(e);
43 }
44 } else {
45 _shared.pullMoveY = screenY(e);
46 }
47
48 if (_shared.state === 'refreshing') {
49 if (e.cancelable && _el.shouldPullToRefresh() && _shared.pullStartY < _shared.pullMoveY) {
50 e.preventDefault();
51 }
52
53 return;
54 }
55
56 if (_shared.state === 'pending') {
57 _el.ptrElement.classList.add(`${_el.classPrefix}pull`);
58 _shared.state = 'pulling';
59 _ptr.update(_el);
60 }
61
62 if (_shared.pullStartY && _shared.pullMoveY) {
63 _shared.dist = _shared.pullMoveY - _shared.pullStartY;
64 }
65
66 _shared.distExtra = _shared.dist - _el.distIgnore;
67
68 if (_shared.distExtra > 0) {
69 if (e.cancelable) {
70 e.preventDefault();
71 }
72
73 _el.ptrElement.style[_el.cssProp] = `${_shared.distResisted}px`;
74
75 _shared.distResisted = _el.resistanceFunction(_shared.distExtra / _el.distThreshold)
76 * Math.min(_el.distMax, _shared.distExtra);
77
78 if (_shared.state === 'pulling' && _shared.distResisted > _el.distThreshold) {
79 _el.ptrElement.classList.add(`${_el.classPrefix}release`);
80 _shared.state = 'releasing';
81 _ptr.update(_el);
82 }
83
84 if (_shared.state === 'releasing' && _shared.distResisted < _el.distThreshold) {
85 _el.ptrElement.classList.remove(`${_el.classPrefix}release`);
86 _shared.state = 'pulling';
87 _ptr.update(_el);
88 }
89 }
90 }
91
92 function _onTouchEnd() {

Callers

nothing calls this directly

Calls 1

screenYFunction · 0.85

Tested by

no test coverage detected