fastman2 2.9.0 → 3.0.0-alpha.1

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.
@@ -1 +1,356 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fastman=e():t.fastman=e()}(this,function(){return webpackJsonpfastman([8],{231:function(t,e,n){t.exports=n(51)},3:function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},51:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(59);e.default=o},59:function(t,e,n){(function(e){function n(t,n,o){var r={container:e.document.body,offset:0,debounce:15,failsafe:150};void 0!==n&&"function"!=typeof n||(o=n,n={});var c=r.container=n.container||r.container,u=r.offset=n.offset||r.offset,a=r.debounce=n.debounce||r.debounce,s=r.failsafe=n.failsafe||r.failsafe;!0===s?s=150:!1===s&&(s=0),s>0&&s<a&&(s=a+50);for(var l=0;l<f.length;l++)if(f[l].container===c&&f[l]._debounce===a&&f[l]._failsafe===s)return f[l].isInViewport(t,u,o);return f[f.push(i(c,a,s))-1].isInViewport(t,u,o)}function o(t,e,n){t.attachEvent?t.attachEvent("on"+e,n):t.addEventListener(e,n,!1)}function r(t,e,n){var o;return function(){function r(){o=null,n||t.apply(i,c)}var i=this,c=arguments,u=n&&!o;clearTimeout(o),o=setTimeout(r,e),u&&t.apply(i,c)}}function i(t,n,i){function f(t,e,n){if(!n)return m(t,e);var o=l(t,e,n);return o.watch(),o}function l(t,e,n){function o(){p.add(t,e,n)}function r(){p.remove(t)}return{watch:o,dispose:r}}function d(t,e,n){m(t,e)&&(p.remove(t),n(t))}function m(n,o){if(!n)return!1;if(!s(e.document.documentElement,n)||!s(e.document.documentElement,t))return!1;if(!n.offsetWidth||!n.offsetHeight)return!1;var r=n.getBoundingClientRect(),i={};if(t===e.document.body)i={top:-o,left:-o,right:e.document.documentElement.clientWidth+o,bottom:e.document.documentElement.clientHeight+o};else{var c=t.getBoundingClientRect();i={top:c.top-o,left:c.left-o,right:c.right+o,bottom:c.bottom+o}}return r.right>=i.left&&r.left<=i.right&&r.bottom>=i.top&&r.top<=i.bottom}var p=c(),h=t===e.document.body?e:t,v=r(p.checkAll(d),n);return o(h,"scroll",v),h===e&&o(e,"resize",v),a&&u(p,t,v),i>0&&setInterval(v,i),{container:t,isInViewport:f,_debounce:n,_failsafe:i}}function c(){function t(t,e,n){o(t)||i.push([t,e,n])}function e(t){var e=n(t);-1!==e&&i.splice(e,1)}function n(t){for(var e=i.length-1;e>=0;e--)if(i[e][0]===t)return e;return-1}function o(t){return-1!==n(t)}function r(t){return function(){for(var e=i.length-1;e>=0;e--)t.apply(this,i[e])}}var i=[];return{add:t,remove:e,isWatched:o,checkAll:r}}function u(t,e,n){function o(t){!0===t.some(r)&&setTimeout(n,0)}function r(e){var n=u.call([],Array.prototype.slice.call(e.addedNodes),e.target);return c.call(n,t.isWatched).length>0}var i=new MutationObserver(o),c=Array.prototype.filter,u=Array.prototype.concat;i.observe(e,{childList:!0,subtree:!0,attributes:!0})}t.exports=n;var f=[],a="function"==typeof e.MutationObserver,s=function(){return!e.document||(e.document.documentElement.compareDocumentPosition?function(t,e){return!!(16&t.compareDocumentPosition(e))}:e.document.documentElement.contains?function(t,e){return t!==e&&!!t.contains&&t.contains(e)}:function(t,e){for(;e=e.parentNode;)if(e===t)return!0;return!1})}}).call(e,n(3))}},[231])});
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["fastman"] = factory();
8
+ else
9
+ root["fastman"] = factory();
10
+ })(this, function() {
11
+ return webpackJsonpfastman([8],{
12
+
13
+ /***/ 231:
14
+ /***/ (function(module, exports, __webpack_require__) {
15
+
16
+ module.exports = __webpack_require__(51);
17
+
18
+
19
+ /***/ }),
20
+
21
+ /***/ 3:
22
+ /***/ (function(module, exports) {
23
+
24
+ var g;
25
+
26
+ // This works in non-strict mode
27
+ g = (function() {
28
+ return this;
29
+ })();
30
+
31
+ try {
32
+ // This works if eval is allowed (see CSP)
33
+ g = g || Function("return this")() || (1,eval)("this");
34
+ } catch(e) {
35
+ // This works if the window reference is available
36
+ if(typeof window === "object")
37
+ g = window;
38
+ }
39
+
40
+ // g can still be undefined, but nothing to do about it...
41
+ // We return undefined, instead of nothing here, so it's
42
+ // easier to handle this case. if(!global) { ...}
43
+
44
+ module.exports = g;
45
+
46
+
47
+ /***/ }),
48
+
49
+ /***/ 51:
50
+ /***/ (function(module, exports, __webpack_require__) {
51
+
52
+ "use strict";
53
+
54
+
55
+ Object.defineProperty(exports, "__esModule", {
56
+ value: true
57
+ });
58
+ /**
59
+ * Created by dfzq on 2017/8/14.
60
+ */
61
+ var inViewport = __webpack_require__(59);
62
+ exports.default = inViewport;
63
+
64
+ /***/ }),
65
+
66
+ /***/ 59:
67
+ /***/ (function(module, exports, __webpack_require__) {
68
+
69
+ /* WEBPACK VAR INJECTION */(function(global) {module.exports = inViewport;
70
+
71
+ var instances = [];
72
+ var supportsMutationObserver = typeof global.MutationObserver === 'function';
73
+
74
+ function inViewport(elt, params, cb) {
75
+ var opts = {
76
+ container: global.document.body,
77
+ offset: 0,
78
+ debounce: 15,
79
+ failsafe: 150
80
+ };
81
+
82
+ if (params === undefined || typeof params === 'function') {
83
+ cb = params;
84
+ params = {};
85
+ }
86
+
87
+ var container = opts.container = params.container || opts.container;
88
+ var offset = opts.offset = params.offset || opts.offset;
89
+ var debounceValue = opts.debounce = params.debounce || opts.debounce;
90
+ var failsafe = opts.failsafe = params.failsafe || opts.failsafe;
91
+
92
+ // ensure backward compatibility with failsafe as boolean
93
+ if (failsafe === true) {
94
+ failsafe = 150;
95
+ } else if(failsafe === false) {
96
+ failsafe = 0;
97
+ }
98
+
99
+ // failsafe check always needs to be higher than debounceValue
100
+ if (failsafe > 0 && failsafe < debounceValue) {
101
+ failsafe = debounceValue + 50;
102
+ }
103
+
104
+ for (var i = 0; i < instances.length; i++) {
105
+ if (
106
+ instances[i].container === container &&
107
+ instances[i]._debounce === debounceValue &&
108
+ instances[i]._failsafe === failsafe
109
+ ) {
110
+ return instances[i].isInViewport(elt, offset, cb);
111
+ }
112
+ }
113
+
114
+ return instances[
115
+ instances.push(createInViewport(container, debounceValue, failsafe)) - 1
116
+ ].isInViewport(elt, offset, cb);
117
+ }
118
+
119
+ function addEvent(el, type, fn) {
120
+ if (el.attachEvent) {
121
+ el.attachEvent('on' + type, fn);
122
+ } else {
123
+ el.addEventListener(type, fn, false);
124
+ }
125
+ }
126
+
127
+ function debounce(func, wait, immediate) {
128
+ var timeout;
129
+ return function () {
130
+ var context = this, args = arguments;
131
+ var callNow = immediate && !timeout;
132
+ clearTimeout(timeout);
133
+ timeout = setTimeout(later, wait);
134
+ if (callNow) func.apply(context, args);
135
+
136
+ function later() {
137
+ timeout = null;
138
+ if (!immediate) func.apply(context, args);
139
+ }
140
+ };
141
+ }
142
+
143
+ // https://github.com/jquery/sizzle/blob/3136f48b90e3edc84cbaaa6f6f7734ef03775a07/sizzle.js#L708
144
+ var contains = function() {
145
+ if (!global.document) {
146
+ return true;
147
+ }
148
+ return global.document.documentElement.compareDocumentPosition ?
149
+ function (a, b) {
150
+ return !!(a.compareDocumentPosition(b) & 16);
151
+ } :
152
+ global.document.documentElement.contains ?
153
+ function (a, b) {
154
+ return a !== b && ( a.contains ? a.contains(b) : false );
155
+ } :
156
+ function (a, b) {
157
+ while (b = b.parentNode) {
158
+ if (b === a) {
159
+ return true;
160
+ }
161
+ }
162
+ return false;
163
+ };
164
+ }
165
+
166
+ function createInViewport(container, debounceValue, failsafe) {
167
+ var watches = createWatches();
168
+
169
+ var scrollContainer = container === global.document.body ? global : container;
170
+ var debouncedCheck = debounce(watches.checkAll(watchInViewport), debounceValue);
171
+
172
+ addEvent(scrollContainer, 'scroll', debouncedCheck);
173
+
174
+ if (scrollContainer === global) {
175
+ addEvent(global, 'resize', debouncedCheck);
176
+ }
177
+
178
+ if (supportsMutationObserver) {
179
+ observeDOM(watches, container, debouncedCheck);
180
+ }
181
+
182
+ // failsafe check, every X we check for visible images
183
+ // usecase: a hidden parent containing eleements
184
+ // when the parent becomes visible, we have no event that the children
185
+ // became visible
186
+ if (failsafe > 0) {
187
+ setInterval(debouncedCheck, failsafe);
188
+ }
189
+
190
+ function isInViewport(elt, offset, cb) {
191
+ if (!cb) {
192
+ return isVisible(elt, offset);
193
+ }
194
+
195
+ var remote = createRemote(elt, offset, cb);
196
+ remote.watch();
197
+ return remote;
198
+ }
199
+
200
+ function createRemote(elt, offset, cb) {
201
+ function watch() {
202
+ watches.add(elt, offset, cb);
203
+ }
204
+
205
+ function dispose() {
206
+ watches.remove(elt);
207
+ }
208
+
209
+ return {
210
+ watch: watch,
211
+ dispose: dispose
212
+ };
213
+ }
214
+
215
+ function watchInViewport(elt, offset, cb) {
216
+ if (isVisible(elt, offset)) {
217
+ watches.remove(elt);
218
+ cb(elt);
219
+ }
220
+ }
221
+
222
+ function isVisible(elt, offset) {
223
+ if (!elt) {
224
+ return false;
225
+ }
226
+
227
+ if (!contains(global.document.documentElement, elt) || !contains(global.document.documentElement, container)) {
228
+ return false;
229
+ }
230
+
231
+ // Check if the element is visible
232
+ // https://github.com/jquery/jquery/blob/740e190223d19a114d5373758127285d14d6b71e/src/css/hiddenVisibleSelectors.js
233
+ if (!elt.offsetWidth || !elt.offsetHeight) {
234
+ return false;
235
+ }
236
+
237
+ var eltRect = elt.getBoundingClientRect();
238
+ var viewport = {};
239
+
240
+ if (container === global.document.body) {
241
+ viewport = {
242
+ top: -offset,
243
+ left: -offset,
244
+ right: global.document.documentElement.clientWidth + offset,
245
+ bottom: global.document.documentElement.clientHeight + offset
246
+ };
247
+ } else {
248
+ var containerRect = container.getBoundingClientRect();
249
+ viewport = {
250
+ top: containerRect.top - offset,
251
+ left: containerRect.left - offset,
252
+ right: containerRect.right + offset,
253
+ bottom: containerRect.bottom + offset
254
+ };
255
+ }
256
+
257
+ // The element must overlap with the visible part of the viewport
258
+ var visible =
259
+ (
260
+ eltRect.right >= viewport.left &&
261
+ eltRect.left <= viewport.right &&
262
+ eltRect.bottom >= viewport.top &&
263
+ eltRect.top <= viewport.bottom
264
+ );
265
+
266
+ return visible;
267
+ }
268
+
269
+ return {
270
+ container: container,
271
+ isInViewport: isInViewport,
272
+ _debounce: debounceValue,
273
+ _failsafe: failsafe
274
+ };
275
+ }
276
+
277
+ function createWatches() {
278
+ var watches = [];
279
+
280
+ function add(elt, offset, cb) {
281
+ if (!isWatched(elt)) {
282
+ watches.push([elt, offset, cb]);
283
+ }
284
+ }
285
+
286
+ function remove(elt) {
287
+ var pos = indexOf(elt);
288
+ if (pos !== -1) {
289
+ watches.splice(pos, 1);
290
+ }
291
+ }
292
+
293
+ function indexOf(elt) {
294
+ for (var i = watches.length - 1; i >= 0; i--) {
295
+ if (watches[i][0] === elt) {
296
+ return i;
297
+ }
298
+ }
299
+ return -1;
300
+ }
301
+
302
+ function isWatched(elt) {
303
+ return indexOf(elt) !== -1;
304
+ }
305
+
306
+ function checkAll(cb) {
307
+ return function () {
308
+ for (var i = watches.length - 1; i >= 0; i--) {
309
+ cb.apply(this, watches[i]);
310
+ }
311
+ };
312
+ }
313
+
314
+ return {
315
+ add: add,
316
+ remove: remove,
317
+ isWatched: isWatched,
318
+ checkAll: checkAll
319
+ };
320
+ }
321
+
322
+ function observeDOM(watches, container, cb) {
323
+ var observer = new MutationObserver(watch);
324
+ var filter = Array.prototype.filter;
325
+ var concat = Array.prototype.concat;
326
+
327
+ observer.observe(container, {
328
+ childList: true,
329
+ subtree: true,
330
+ // changes like style/width/height/display will be catched
331
+ attributes: true
332
+ });
333
+
334
+ function watch(mutations) {
335
+ // some new DOM nodes where previously watched
336
+ // we should check their positions
337
+ if (mutations.some(knownNodes) === true) {
338
+ setTimeout(cb, 0);
339
+ }
340
+ }
341
+
342
+ function knownNodes(mutation) {
343
+ var nodes = concat.call([],
344
+ Array.prototype.slice.call(mutation.addedNodes),
345
+ mutation.target
346
+ );
347
+ return filter.call(nodes, watches.isWatched).length > 0;
348
+ }
349
+ }
350
+
351
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))
352
+
353
+ /***/ })
354
+
355
+ },[231]);
356
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastman2",
3
- "version": "2.9.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "a hybird app framework",
5
5
  "main": "index.js",
6
6
  "scripts": {