revas 1.0.2 → 2.0.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/README.md +61 -1
- package/dist/chunk-JPUKLNW3.js +1710 -0
- package/dist/chunk-JPUKLNW3.js.map +1 -0
- package/dist/revas-common.cjs +1768 -0
- package/dist/revas-common.cjs.map +1 -0
- package/dist/revas-common.d.cts +363 -0
- package/dist/revas-common.d.ts +363 -0
- package/dist/revas-common.js +3 -0
- package/dist/revas-common.js.map +1 -0
- package/dist/revas.cjs +1881 -0
- package/dist/revas.cjs.map +1 -0
- package/dist/revas.d.cts +13 -0
- package/dist/revas.d.ts +13 -0
- package/dist/revas.js +108 -1967
- package/dist/revas.js.map +1 -1
- package/package.json +58 -45
- package/.eslintcache +0 -1
- package/common.d.ts +0 -1
- package/common.js +0 -1
- package/dist/revas.common.js +0 -1861
- package/dist/revas.common.js.map +0 -1
- package/dist/revas.es.js +0 -1932
- package/dist/revas.es.js.map +0 -1
- package/dist/types/develop/App.d.ts +0 -8
- package/dist/types/develop/Intro/About.d.ts +0 -2
- package/dist/types/develop/Intro/Animation.d.ts +0 -2
- package/dist/types/develop/Intro/Component.d.ts +0 -2
- package/dist/types/develop/Intro/Entry.d.ts +0 -6
- package/dist/types/develop/Intro/Gesture.d.ts +0 -2
- package/dist/types/develop/Intro/Interactable.d.ts +0 -10
- package/dist/types/develop/Intro/Navbar.d.ts +0 -6
- package/dist/types/develop/Intro/Panel.d.ts +0 -14
- package/dist/types/develop/Intro/Style.d.ts +0 -2
- package/dist/types/develop/Intro/index.d.ts +0 -2
- package/dist/types/develop/Music/Player.d.ts +0 -79
- package/dist/types/develop/Music/data.d.ts +0 -8
- package/dist/types/develop/Music/index.d.ts +0 -23
- package/dist/types/develop/Music/styles.d.ts +0 -19
- package/dist/types/develop/Timeline/data.d.ts +0 -5
- package/dist/types/develop/Timeline/index.d.ts +0 -11
- package/dist/types/develop/common/back.d.ts +0 -2
- package/dist/types/develop/common/simple-router.d.ts +0 -44
- package/dist/types/develop/serviceWorker.d.ts +0 -7
- package/dist/types/index.d.ts +0 -1
- package/dist/types/revas/common.d.ts +0 -24
- package/dist/types/revas/components/Context.d.ts +0 -12
- package/dist/types/revas/components/Image.d.ts +0 -20
- package/dist/types/revas/components/LinearGradient.d.ts +0 -38
- package/dist/types/revas/components/ListView.d.ts +0 -22
- package/dist/types/revas/components/ScrollView.d.ts +0 -43
- package/dist/types/revas/components/Text.d.ts +0 -16
- package/dist/types/revas/components/Touchable.d.ts +0 -34
- package/dist/types/revas/components/View.d.ts +0 -3
- package/dist/types/revas/components/common/Scroller.d.ts +0 -35
- package/dist/types/revas/components/common/drawImage.d.ts +0 -3
- package/dist/types/revas/components/common/drawText.d.ts +0 -17
- package/dist/types/revas/components/common/imageLoader.d.ts +0 -2
- package/dist/types/revas/core/Animated.d.ts +0 -59
- package/dist/types/revas/core/Canvas.d.ts +0 -17
- package/dist/types/revas/core/Container.d.ts +0 -18
- package/dist/types/revas/core/Node.d.ts +0 -46
- package/dist/types/revas/core/css-layout/index.d.ts +0 -9
- package/dist/types/revas/core/draw.d.ts +0 -4
- package/dist/types/revas/core/offscreen.d.ts +0 -11
- package/dist/types/revas/core/reconciler.d.ts +0 -5
- package/dist/types/revas/core/touch.d.ts +0 -3
- package/dist/types/revas/core/utils.d.ts +0 -22
- package/dist/types/revas/core/yoga-layout/index.d.ts +0 -3
- package/dist/types/revas/core/yoga-layout/init.d.ts +0 -3
- package/dist/types/revas/core/yoga-layout/style.d.ts +0 -3
- package/dist/types/revas/index.d.ts +0 -2
- package/dist/types/revas/web/index.d.ts +0 -1
- package/dist/types/revas/web/render.d.ts +0 -7
- package/doc/API.md +0 -241
- package/doc/README-zh.md +0 -266
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -64
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -2
- package/public/stats.min.js +0 -5
- package/public/touch-emulator.js +0 -363
- package/rollup.config.ts +0 -44
- package/tsconfig.json +0 -30
package/public/index.html
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8" />
|
|
6
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
7
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
|
8
|
-
<meta name="theme-color" content="#000000" />
|
|
9
|
-
<meta name="description" content="Web site created using create-react-app" />
|
|
10
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
11
|
-
<!--
|
|
12
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
13
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
14
|
-
-->
|
|
15
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
16
|
-
<!--
|
|
17
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
18
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
19
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
20
|
-
|
|
21
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
22
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
23
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
24
|
-
-->
|
|
25
|
-
<title>Revas</title>
|
|
26
|
-
<script src="%PUBLIC_URL%/touch-emulator.js"></script>
|
|
27
|
-
<script src="%PUBLIC_URL%/stats.min.js"></script>
|
|
28
|
-
<!-- <script src="//cdn.jsdelivr.net/npm/eruda"></script>
|
|
29
|
-
<script>eruda.init();</script>
|
|
30
|
-
<script>
|
|
31
|
-
window.onerror = function (e) { console.log(JSON.stringify(arguments)) }
|
|
32
|
-
</script> -->
|
|
33
|
-
</head>
|
|
34
|
-
|
|
35
|
-
<body>
|
|
36
|
-
<div id="canvas">
|
|
37
|
-
</div>
|
|
38
|
-
</body>
|
|
39
|
-
<script type="text/javascript">
|
|
40
|
-
TouchEmulator();
|
|
41
|
-
if (location.host.indexOf(':') > 0) {
|
|
42
|
-
const stats = new Stats();
|
|
43
|
-
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
|
|
44
|
-
stats.dom.setAttribute('style', `
|
|
45
|
-
position: fixed;
|
|
46
|
-
top: 1px;
|
|
47
|
-
right: 1px;
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
opacity: 0.9;
|
|
50
|
-
z-index: 10000;`)
|
|
51
|
-
document.body.appendChild(stats.dom);
|
|
52
|
-
|
|
53
|
-
const animate = () => {
|
|
54
|
-
stats.begin();
|
|
55
|
-
|
|
56
|
-
// monitored code goes here
|
|
57
|
-
stats.end()
|
|
58
|
-
requestAnimationFrame(animate);
|
|
59
|
-
}
|
|
60
|
-
requestAnimationFrame(animate);
|
|
61
|
-
}
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
</html>
|
package/public/logo192.png
DELETED
|
Binary file
|
package/public/logo512.png
DELETED
|
Binary file
|
package/public/manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"short_name": "Revas Demo",
|
|
3
|
-
"name": "Revas Demo",
|
|
4
|
-
"icons": [
|
|
5
|
-
{
|
|
6
|
-
"src": "favicon.ico",
|
|
7
|
-
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
-
"type": "image/x-icon"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"src": "logo192.png",
|
|
12
|
-
"type": "image/png",
|
|
13
|
-
"sizes": "192x192"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"src": "logo512.png",
|
|
17
|
-
"type": "image/png",
|
|
18
|
-
"sizes": "512x512"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"start_url": ".",
|
|
22
|
-
"display": "standalone",
|
|
23
|
-
"theme_color": "#000000",
|
|
24
|
-
"background_color": "#333"
|
|
25
|
-
}
|
package/public/robots.txt
DELETED
package/public/stats.min.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// stats.js - http://github.com/mrdoob/stats.js
|
|
2
|
-
(function(f,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"===typeof define&&define.amd?define(e):f.Stats=e()})(this,function(){var f=function(){function e(a){c.appendChild(a.dom);return a}function u(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();
|
|
3
|
-
u(++l%c.children.length)},!1);var k=(performance||Date).now(),g=k,a=0,r=e(new f.Panel("FPS","#0ff","#002")),h=e(new f.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var t=e(new f.Panel("MB","#f08","#201"));u(0);return{REVISION:16,dom:c,addPanel:e,showPanel:u,begin:function(){k=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();h.update(c-k,200);if(c>=g+1E3&&(r.update(1E3*a/(c-g),100),g=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/
|
|
4
|
-
1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){k=this.end()},domElement:c,setMode:u}};f.Panel=function(e,f,l){var c=Infinity,k=0,g=Math.round,a=g(window.devicePixelRatio||1),r=80*a,h=48*a,t=3*a,v=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=h;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,h);b.fillStyle=f;b.fillText(e,t,v);
|
|
5
|
-
b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(h,w){c=Math.min(c,h);k=Math.max(k,h);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=f;b.fillText(g(h)+" "+e+" ("+g(c)+"-"+g(k)+")",t,v);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,g((1-h/w)*p))}}};return f});
|
package/public/touch-emulator.js
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
// https://github.com/hammerjs/touchemulator
|
|
2
|
-
|
|
3
|
-
(function(window, document, exportName, undefined) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
var isMultiTouch = false;
|
|
7
|
-
var multiTouchStartPos;
|
|
8
|
-
var eventTarget;
|
|
9
|
-
var touchElements = {};
|
|
10
|
-
|
|
11
|
-
// polyfills
|
|
12
|
-
if(!document.createTouch) {
|
|
13
|
-
document.createTouch = function(view, target, identifier, pageX, pageY, screenX, screenY, clientX, clientY) {
|
|
14
|
-
// auto set
|
|
15
|
-
if(clientX == undefined || clientY == undefined) {
|
|
16
|
-
clientX = pageX - window.pageXOffset;
|
|
17
|
-
clientY = pageY - window.pageYOffset;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return new Touch(target, identifier, {
|
|
21
|
-
pageX: pageX,
|
|
22
|
-
pageY: pageY,
|
|
23
|
-
screenX: screenX,
|
|
24
|
-
screenY: screenY,
|
|
25
|
-
clientX: clientX,
|
|
26
|
-
clientY: clientY
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if(!document.createTouchList) {
|
|
32
|
-
document.createTouchList = function() {
|
|
33
|
-
var touchList = new TouchList();
|
|
34
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
35
|
-
touchList[i] = arguments[i];
|
|
36
|
-
}
|
|
37
|
-
touchList.length = arguments.length;
|
|
38
|
-
return touchList;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* create an touch point
|
|
44
|
-
* @constructor
|
|
45
|
-
* @param target
|
|
46
|
-
* @param identifier
|
|
47
|
-
* @param pos
|
|
48
|
-
* @param deltaX
|
|
49
|
-
* @param deltaY
|
|
50
|
-
* @returns {Object} touchPoint
|
|
51
|
-
*/
|
|
52
|
-
function Touch(target, identifier, pos, deltaX, deltaY) {
|
|
53
|
-
deltaX = deltaX || 0;
|
|
54
|
-
deltaY = deltaY || 0;
|
|
55
|
-
|
|
56
|
-
this.identifier = identifier;
|
|
57
|
-
this.target = target;
|
|
58
|
-
this.clientX = pos.clientX + deltaX;
|
|
59
|
-
this.clientY = pos.clientY + deltaY;
|
|
60
|
-
this.screenX = pos.screenX + deltaX;
|
|
61
|
-
this.screenY = pos.screenY + deltaY;
|
|
62
|
-
this.pageX = pos.pageX + deltaX;
|
|
63
|
-
this.pageY = pos.pageY + deltaY;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* create empty touchlist with the methods
|
|
68
|
-
* @constructor
|
|
69
|
-
* @returns touchList
|
|
70
|
-
*/
|
|
71
|
-
function TouchList() {
|
|
72
|
-
var touchList = [];
|
|
73
|
-
|
|
74
|
-
touchList.item = function(index) {
|
|
75
|
-
return this[index] || null;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// specified by Mozilla
|
|
79
|
-
touchList.identifiedTouch = function(id) {
|
|
80
|
-
return this[id + 1] || null;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return touchList;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Simple trick to fake touch event support
|
|
89
|
-
* this is enough for most libraries like Modernizr and Hammer
|
|
90
|
-
*/
|
|
91
|
-
function fakeTouchSupport() {
|
|
92
|
-
var objs = [window, document.documentElement];
|
|
93
|
-
var props = ['ontouchstart', 'ontouchmove', 'ontouchcancel', 'ontouchend'];
|
|
94
|
-
|
|
95
|
-
for(var o=0; o<objs.length; o++) {
|
|
96
|
-
for(var p=0; p<props.length; p++) {
|
|
97
|
-
if(objs[o] && objs[o][props[p]] == undefined) {
|
|
98
|
-
objs[o][props[p]] = null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* we don't have to emulate on a touch device
|
|
106
|
-
* @returns {boolean}
|
|
107
|
-
*/
|
|
108
|
-
function hasTouchSupport() {
|
|
109
|
-
return ("ontouchstart" in window) || // touch events
|
|
110
|
-
(window.Modernizr && window.Modernizr.touch) || // modernizr
|
|
111
|
-
(navigator.msMaxTouchPoints || navigator.maxTouchPoints) > 2; // pointer events
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* disable mouseevents on the page
|
|
116
|
-
* @param ev
|
|
117
|
-
*/
|
|
118
|
-
function preventMouseEvents(ev) {
|
|
119
|
-
ev.preventDefault();
|
|
120
|
-
ev.stopPropagation();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* only trigger touches when the left mousebutton has been pressed
|
|
125
|
-
* @param touchType
|
|
126
|
-
* @returns {Function}
|
|
127
|
-
*/
|
|
128
|
-
function onMouse(touchType) {
|
|
129
|
-
return function(ev) {
|
|
130
|
-
// prevent mouse events
|
|
131
|
-
preventMouseEvents(ev);
|
|
132
|
-
|
|
133
|
-
if (ev.which !== 1) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// The EventTarget on which the touch point started when it was first placed on the surface,
|
|
138
|
-
// even if the touch point has since moved outside the interactive area of that element.
|
|
139
|
-
// also, when the target doesnt exist anymore, we update it
|
|
140
|
-
if (ev.type == 'mousedown' || !eventTarget || (eventTarget && !eventTarget.dispatchEvent)) {
|
|
141
|
-
eventTarget = ev.target;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// shiftKey has been lost, so trigger a touchend
|
|
145
|
-
if (isMultiTouch && !ev.shiftKey) {
|
|
146
|
-
triggerTouch('touchend', ev);
|
|
147
|
-
isMultiTouch = false;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
triggerTouch(touchType, ev);
|
|
151
|
-
|
|
152
|
-
// we're entering the multi-touch mode!
|
|
153
|
-
if (!isMultiTouch && ev.shiftKey) {
|
|
154
|
-
isMultiTouch = true;
|
|
155
|
-
multiTouchStartPos = {
|
|
156
|
-
pageX: ev.pageX,
|
|
157
|
-
pageY: ev.pageY,
|
|
158
|
-
clientX: ev.clientX,
|
|
159
|
-
clientY: ev.clientY,
|
|
160
|
-
screenX: ev.screenX,
|
|
161
|
-
screenY: ev.screenY
|
|
162
|
-
};
|
|
163
|
-
triggerTouch('touchstart', ev);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// reset
|
|
167
|
-
if (ev.type == 'mouseup') {
|
|
168
|
-
multiTouchStartPos = null;
|
|
169
|
-
isMultiTouch = false;
|
|
170
|
-
eventTarget = null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* trigger a touch event
|
|
177
|
-
* @param eventName
|
|
178
|
-
* @param mouseEv
|
|
179
|
-
*/
|
|
180
|
-
function triggerTouch(eventName, mouseEv) {
|
|
181
|
-
var touchEvent = document.createEvent('Event');
|
|
182
|
-
touchEvent.initEvent(eventName, true, true);
|
|
183
|
-
|
|
184
|
-
touchEvent.altKey = mouseEv.altKey;
|
|
185
|
-
touchEvent.ctrlKey = mouseEv.ctrlKey;
|
|
186
|
-
touchEvent.metaKey = mouseEv.metaKey;
|
|
187
|
-
touchEvent.shiftKey = mouseEv.shiftKey;
|
|
188
|
-
|
|
189
|
-
touchEvent.touches = getActiveTouches(mouseEv, eventName);
|
|
190
|
-
touchEvent.targetTouches = getActiveTouches(mouseEv, eventName);
|
|
191
|
-
touchEvent.changedTouches = getChangedTouches(mouseEv, eventName);
|
|
192
|
-
|
|
193
|
-
eventTarget.dispatchEvent(touchEvent);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* create a touchList based on the mouse event
|
|
198
|
-
* @param mouseEv
|
|
199
|
-
* @returns {TouchList}
|
|
200
|
-
*/
|
|
201
|
-
function createTouchList(mouseEv) {
|
|
202
|
-
var touchList = new TouchList();
|
|
203
|
-
|
|
204
|
-
if (isMultiTouch) {
|
|
205
|
-
var f = TouchEmulator.multiTouchOffset;
|
|
206
|
-
var deltaX = multiTouchStartPos.pageX - mouseEv.pageX;
|
|
207
|
-
var deltaY = multiTouchStartPos.pageY - mouseEv.pageY;
|
|
208
|
-
|
|
209
|
-
touchList.push(new Touch(eventTarget, 1, multiTouchStartPos, (deltaX*-1) - f, (deltaY*-1) + f));
|
|
210
|
-
touchList.push(new Touch(eventTarget, 2, multiTouchStartPos, deltaX+f, deltaY-f));
|
|
211
|
-
} else {
|
|
212
|
-
touchList.push(new Touch(eventTarget, 1, mouseEv, 0, 0));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return touchList;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* receive all active touches
|
|
220
|
-
* @param mouseEv
|
|
221
|
-
* @returns {TouchList}
|
|
222
|
-
*/
|
|
223
|
-
function getActiveTouches(mouseEv, eventName) {
|
|
224
|
-
// empty list
|
|
225
|
-
if (mouseEv.type == 'mouseup') {
|
|
226
|
-
return new TouchList();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
var touchList = createTouchList(mouseEv);
|
|
230
|
-
if(isMultiTouch && mouseEv.type != 'mouseup' && eventName == 'touchend') {
|
|
231
|
-
touchList.splice(1, 1);
|
|
232
|
-
}
|
|
233
|
-
return touchList;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* receive a filtered set of touches with only the changed pointers
|
|
238
|
-
* @param mouseEv
|
|
239
|
-
* @param eventName
|
|
240
|
-
* @returns {TouchList}
|
|
241
|
-
*/
|
|
242
|
-
function getChangedTouches(mouseEv, eventName) {
|
|
243
|
-
var touchList = createTouchList(mouseEv);
|
|
244
|
-
|
|
245
|
-
// we only want to return the added/removed item on multitouch
|
|
246
|
-
// which is the second pointer, so remove the first pointer from the touchList
|
|
247
|
-
//
|
|
248
|
-
// but when the mouseEv.type is mouseup, we want to send all touches because then
|
|
249
|
-
// no new input will be possible
|
|
250
|
-
if(isMultiTouch && mouseEv.type != 'mouseup' &&
|
|
251
|
-
(eventName == 'touchstart' || eventName == 'touchend')) {
|
|
252
|
-
touchList.splice(0, 1);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return touchList;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* show the touchpoints on the screen
|
|
260
|
-
*/
|
|
261
|
-
function showTouches(ev) {
|
|
262
|
-
var touch, i, el, styles;
|
|
263
|
-
|
|
264
|
-
// first all visible touches
|
|
265
|
-
for(i = 0; i < ev.touches.length; i++) {
|
|
266
|
-
touch = ev.touches[i];
|
|
267
|
-
el = touchElements[touch.identifier];
|
|
268
|
-
if(!el) {
|
|
269
|
-
el = touchElements[touch.identifier] = document.createElement("div");
|
|
270
|
-
document.body.appendChild(el);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
styles = TouchEmulator.template(touch);
|
|
274
|
-
for(var prop in styles) {
|
|
275
|
-
el.style[prop] = styles[prop];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// remove all ended touches
|
|
280
|
-
if(ev.type == 'touchend' || ev.type == 'touchcancel') {
|
|
281
|
-
for(i = 0; i < ev.changedTouches.length; i++) {
|
|
282
|
-
touch = ev.changedTouches[i];
|
|
283
|
-
el = touchElements[touch.identifier];
|
|
284
|
-
if(el) {
|
|
285
|
-
el.parentNode.removeChild(el);
|
|
286
|
-
delete touchElements[touch.identifier];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* TouchEmulator initializer
|
|
294
|
-
*/
|
|
295
|
-
function TouchEmulator() {
|
|
296
|
-
if (hasTouchSupport()) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
fakeTouchSupport();
|
|
301
|
-
|
|
302
|
-
window.addEventListener("mousedown", onMouse('touchstart'), true);
|
|
303
|
-
window.addEventListener("mousemove", onMouse('touchmove'), true);
|
|
304
|
-
window.addEventListener("mouseup", onMouse('touchend'), true);
|
|
305
|
-
|
|
306
|
-
window.addEventListener("mouseenter", preventMouseEvents, true);
|
|
307
|
-
window.addEventListener("mouseleave", preventMouseEvents, true);
|
|
308
|
-
window.addEventListener("mouseout", preventMouseEvents, true);
|
|
309
|
-
window.addEventListener("mouseover", preventMouseEvents, true);
|
|
310
|
-
|
|
311
|
-
// it uses itself!
|
|
312
|
-
window.addEventListener("touchstart", showTouches, false);
|
|
313
|
-
window.addEventListener("touchmove", showTouches, false);
|
|
314
|
-
window.addEventListener("touchend", showTouches, false);
|
|
315
|
-
window.addEventListener("touchcancel", showTouches, false);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// start distance when entering the multitouch mode
|
|
319
|
-
TouchEmulator.multiTouchOffset = 75;
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* css template for the touch rendering
|
|
323
|
-
* @param touch
|
|
324
|
-
* @returns object
|
|
325
|
-
*/
|
|
326
|
-
TouchEmulator.template = function(touch) {
|
|
327
|
-
var size = 30;
|
|
328
|
-
var transform = 'translate('+ (touch.clientX-(size/2)) +'px, '+ (touch.clientY-(size/2)) +'px)';
|
|
329
|
-
return {
|
|
330
|
-
position: 'fixed',
|
|
331
|
-
left: 0,
|
|
332
|
-
top: 0,
|
|
333
|
-
background: '#fff',
|
|
334
|
-
border: 'solid 1px #999',
|
|
335
|
-
opacity: .6,
|
|
336
|
-
borderRadius: '100%',
|
|
337
|
-
height: size + 'px',
|
|
338
|
-
width: size + 'px',
|
|
339
|
-
padding: 0,
|
|
340
|
-
margin: 0,
|
|
341
|
-
display: 'block',
|
|
342
|
-
overflow: 'hidden',
|
|
343
|
-
pointerEvents: 'none',
|
|
344
|
-
webkitUserSelect: 'none',
|
|
345
|
-
mozUserSelect: 'none',
|
|
346
|
-
userSelect: 'none',
|
|
347
|
-
webkitTransform: transform,
|
|
348
|
-
mozTransform: transform,
|
|
349
|
-
transform: transform
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// export
|
|
354
|
-
if (typeof define == "function" && define.amd) {
|
|
355
|
-
define(function() {
|
|
356
|
-
return TouchEmulator;
|
|
357
|
-
});
|
|
358
|
-
} else if (typeof module != "undefined" && module.exports) {
|
|
359
|
-
module.exports = TouchEmulator;
|
|
360
|
-
} else {
|
|
361
|
-
window[exportName] = TouchEmulator;
|
|
362
|
-
}
|
|
363
|
-
})(window, document, "TouchEmulator");
|
package/rollup.config.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import resolve from 'rollup-plugin-node-resolve';
|
|
2
|
-
import commonjs from 'rollup-plugin-commonjs';
|
|
3
|
-
import sourceMaps from 'rollup-plugin-sourcemaps';
|
|
4
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
5
|
-
import json from 'rollup-plugin-json';
|
|
6
|
-
|
|
7
|
-
const pkg = require('./package.json');
|
|
8
|
-
|
|
9
|
-
const BASE_CONFIG = {
|
|
10
|
-
input: 'src/revas/index.ts',
|
|
11
|
-
output: [
|
|
12
|
-
{ file: pkg.main, format: 'cjs', sourcemap: true },
|
|
13
|
-
{ file: pkg.module, format: 'es', sourcemap: true },
|
|
14
|
-
],
|
|
15
|
-
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
|
16
|
-
external: Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies }).concat(['yoga-layout-wasm/asm']),
|
|
17
|
-
watch: {
|
|
18
|
-
include: 'src/revas/**',
|
|
19
|
-
},
|
|
20
|
-
plugins: [
|
|
21
|
-
// Allow json resolution
|
|
22
|
-
json(),
|
|
23
|
-
// Compile TypeScript files
|
|
24
|
-
typescript({ useTsconfigDeclarationDir: true }),
|
|
25
|
-
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
|
|
26
|
-
commonjs(),
|
|
27
|
-
// Allow node_modules resolution, so you can use 'external' to control
|
|
28
|
-
// which external modules to include in the bundle
|
|
29
|
-
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
|
30
|
-
resolve(),
|
|
31
|
-
|
|
32
|
-
// Resolve source maps to the original source
|
|
33
|
-
sourceMaps(),
|
|
34
|
-
],
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default [
|
|
38
|
-
BASE_CONFIG,
|
|
39
|
-
{
|
|
40
|
-
...BASE_CONFIG,
|
|
41
|
-
input: 'src/revas/common.ts',
|
|
42
|
-
output: [{ file: 'dist/revas.common.js', format: 'cjs', sourcemap: true }],
|
|
43
|
-
},
|
|
44
|
-
];
|
package/tsconfig.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"experimentalDecorators": true,
|
|
20
|
-
"declarationDir": "dist/types",
|
|
21
|
-
"outDir": "dist/raw",
|
|
22
|
-
"noEmit": true,
|
|
23
|
-
"jsx": "react-jsx",
|
|
24
|
-
"allowJs": true,
|
|
25
|
-
"noFallthroughCasesInSwitch": true
|
|
26
|
-
},
|
|
27
|
-
"include": [
|
|
28
|
-
"src"
|
|
29
|
-
]
|
|
30
|
-
}
|