index.jsc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. window.__require = function t(e, i, n) {
  2. function o(l, c) {
  3. if (!i[l]) {
  4. if (!e[l]) {
  5. var s = l.split("/");
  6. s = s[s.length - 1];
  7. if (!e[s]) {
  8. var r = "function" == typeof __require && __require;
  9. if (!c && r) return r(s, !0);
  10. if (a) return a(s, !0);
  11. throw new Error("Cannot find module '" + l + "'");
  12. }
  13. l = s;
  14. }
  15. var h = i[l] = {
  16. exports: {}
  17. };
  18. e[l][0].call(h.exports, function(t) {
  19. return o(e[l][1][t] || t);
  20. }, h, h.exports, t, e, i, n);
  21. }
  22. return i[l].exports;
  23. }
  24. for (var a = "function" == typeof __require && __require, l = 0; l < n.length; l++) o(n[l]);
  25. return o;
  26. }({
  27. UserListView: [ function(t, e) {
  28. "use strict";
  29. cc._RF.push(e, "c57cbOdmz1GWr10rLi+PsQo", "UserListView");
  30. function i(t, e) {
  31. var i;
  32. if ("undefined" == typeof Symbol || null == t[Symbol.iterator]) {
  33. if (Array.isArray(t) || (i = n(t)) || e && t && "number" == typeof t.length) {
  34. i && (t = i);
  35. var o = 0;
  36. return function() {
  37. return o >= t.length ? {
  38. done: !0
  39. } : {
  40. done: !1,
  41. value: t[o++]
  42. };
  43. };
  44. }
  45. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  46. }
  47. return (i = t[Symbol.iterator]()).next.bind(i);
  48. }
  49. function n(t, e) {
  50. if (t) {
  51. if ("string" == typeof t) return o(t, e);
  52. var i = Object.prototype.toString.call(t).slice(8, -1);
  53. "Object" === i && t.constructor && (i = t.constructor.name);
  54. return "Map" === i || "Set" === i ? Array.from(t) : "Arguments" === i || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? o(t, e) : void 0;
  55. }
  56. }
  57. function o(t, e) {
  58. (null == e || e > t.length) && (e = t.length);
  59. for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i];
  60. return n;
  61. }
  62. cc.Class({
  63. extends: cc.Component,
  64. properties: {
  65. scrollView: cc.ScrollView,
  66. bounceBottomCallBack: null,
  67. bounceTopCallBack: null,
  68. scrollEndedCallBack: null,
  69. scrollingCallBack: null,
  70. scrollToBottomCallBack: null,
  71. scrollToTopCallBack: null,
  72. updateItemDataCallBack: null,
  73. isToMoveTop: !1,
  74. spacing: 0,
  75. lengthen: 0
  76. },
  77. onLoad: function() {},
  78. start: function() {},
  79. setDataSet: function(t, e, i) {
  80. this.dataSet = t;
  81. this.parentJs = e;
  82. this.item = i;
  83. },
  84. updateDataSet: function(t, e) {
  85. var i = this;
  86. this.dataSet = t;
  87. this.content.height = this.dataSet.length * (this.itemHeight + this.spacing) + this.spacing + this.lengthen + this.itemHeight;
  88. this.lastStartIndex = -1;
  89. if (e) for (var n = this.content.children, o = 0; o < n.length; o++) o < this.dataSet.length ? this.getView(n[o], n[o]._tag) : n[o].destroy();
  90. this.scheduleOnce(function() {
  91. i.content.height < i.node.height && (i.content.height = i.node.height);
  92. if (this.isToMoveTop) {
  93. this.content.y = Math.floor(this.content.parent.height / 2);
  94. this.isToMoveTop = !1;
  95. }
  96. console.log("****************lastStartIndex=" + this.lastStartIndex + "*****startUpdate=" + i.startUpdate + "*********");
  97. i.startUpdate = !0;
  98. }, .1);
  99. },
  100. initUi: function() {
  101. var t = this;
  102. this.content = this.scrollView.content;
  103. this.lastStartIndex = -1;
  104. this.canScrollToTop = !1;
  105. this.itemNodePool = new cc.NodePool();
  106. var e = this.itemNodePool.get() || cc.instantiate(this.item);
  107. this.itemHeight = e.height;
  108. this.itemsVisibleNumber = Math.ceil(this.content.parent.height / this.itemHeight);
  109. this.content.height = this.dataSet.length * (this.itemHeight + this.spacing) + this.spacing + this.lengthen;
  110. this.scheduleOnce(function() {
  111. t.itemsVisibleNumber = Math.ceil(t.content.parent.height / t.itemHeight);
  112. t.content.height < t.node.height && (t.content.height = t.node.height);
  113. this.content.y = Math.floor(this.content.parent.height / 2);
  114. t.startUpdate = !0;
  115. }, .05);
  116. },
  117. update: function() {
  118. if (this.startUpdate) {
  119. var t = this.checkNeedUpdate();
  120. t >= 0 && this.updateView(t);
  121. }
  122. },
  123. checkNeedUpdate: function() {
  124. var t = Math.ceil(this.content.y) - Math.floor(this.content.parent.height / 2), e = Math.floor(t / (this.itemHeight + this.spacing));
  125. if (e < 0 && !this.canScrollToTop) {
  126. this.scrollView.scrollToTop();
  127. this.canScrollToTop = !0;
  128. return e;
  129. }
  130. e > 0 && (this.canScrollToTop = !1);
  131. if (this.lastStartIndex != e) {
  132. this.lastStartIndex = e;
  133. return e;
  134. }
  135. return -1;
  136. },
  137. updateView: function(t) {
  138. var e = t, n = e + this.itemsVisibleNumber + 5, o = this.dataSet.length;
  139. if (!(e >= o)) {
  140. n > o && (n = o);
  141. for (var a = this.getRecycleItems(e - 3, n), l = 0; l < a.length; l++) this.itemNodePool.put(a[l]);
  142. for (var c, s = i(this.findUpdateIndex(e, n)); !(c = s()).done; ) {
  143. var r = c.value, h = this.getView(this.itemNodePool.get() || cc.instantiate(this.item), r);
  144. h && this.layoutVertical(h, r);
  145. }
  146. }
  147. },
  148. getRecycleItems: function(t, e) {
  149. for (var i = [], n = this.content.children, o = 0; o < n.length; o++) (n[o]._tag < t || n[o]._tag > e) && i.push(n[o]);
  150. return i;
  151. },
  152. findUpdateIndex: function(t, e) {
  153. for (var i = [], n = this.content.children, o = t; o < e; o++) {
  154. for (var a = !1, l = 0; l < n.length; l++) if (o == n[l]._tag) {
  155. a = !0;
  156. break;
  157. }
  158. a || i.push(o);
  159. }
  160. return i;
  161. },
  162. getView: function(t, e) {
  163. if (this.updateItemDataCallBack) {
  164. if (!this.dataSet[e]) {
  165. this.itemNodePool.put(t);
  166. return !1;
  167. }
  168. this.updateItemDataCallBack(t, this.dataSet[e], e);
  169. }
  170. return t;
  171. },
  172. layoutVertical: function(t, e) {
  173. if (cc.isValid(t, !0)) {
  174. this.content.addChild(t);
  175. t._tag = e;
  176. t.setPosition(0, -t.height * (.5 + e) - this.spacing * (e + 1));
  177. }
  178. },
  179. scrollviewEventCallback: function(t, e) {
  180. e == cc.ScrollView.EventType.BOUNCE_BOTTOM ? this.bounceBottomCallBack && this.bounceBottomCallBack() : e == cc.ScrollView.EventType.BOUNCE_TOP ? this.bounceTopCallBack && this.bounceTopCallBack() : e == cc.ScrollView.EventType.SCROLL_ENDED ? this.scrollEndedCallBack && this.scrollEndedCallBack() : e == cc.ScrollView.EventType.SCROLLING ? this.scrollingCallBack && this.scrollingCallBack() : e == cc.ScrollView.EventType.SCROLL_TO_BOTTOM ? this.scrollToBottomCallBack && this.scrollToBottomCallBack() : e == cc.ScrollView.EventType.SCROLL_TO_TOP && this.scrollToTopCallBack && this.scrollToTopCallBack();
  181. },
  182. getData: function() {
  183. return this.dataSet ? this.dataSet : [];
  184. },
  185. getPosition: function(t) {
  186. return -this.itemHeight * (.5 + t) - this.spacing * (t + 1);
  187. },
  188. initSlideBack: function(t) {
  189. HMFUtils.initSlideBack(this.scrollView.node, t);
  190. },
  191. removeChildrenView: function() {
  192. this.scrollView.content.removeAllChildren();
  193. }
  194. });
  195. cc._RF.pop();
  196. }, {} ],
  197. listViewDownToTopJs: [ function(t, e) {
  198. "use strict";
  199. cc._RF.push(e, "d442fQUJbpEhJskHdzo8ird", "listViewDownToTopJs");
  200. function i(t, e) {
  201. var i;
  202. if ("undefined" == typeof Symbol || null == t[Symbol.iterator]) {
  203. if (Array.isArray(t) || (i = n(t)) || e && t && "number" == typeof t.length) {
  204. i && (t = i);
  205. var o = 0;
  206. return function() {
  207. return o >= t.length ? {
  208. done: !0
  209. } : {
  210. done: !1,
  211. value: t[o++]
  212. };
  213. };
  214. }
  215. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  216. }
  217. return (i = t[Symbol.iterator]()).next.bind(i);
  218. }
  219. function n(t, e) {
  220. if (t) {
  221. if ("string" == typeof t) return o(t, e);
  222. var i = Object.prototype.toString.call(t).slice(8, -1);
  223. "Object" === i && t.constructor && (i = t.constructor.name);
  224. return "Map" === i || "Set" === i ? Array.from(t) : "Arguments" === i || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? o(t, e) : void 0;
  225. }
  226. }
  227. function o(t, e) {
  228. (null == e || e > t.length) && (e = t.length);
  229. for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i];
  230. return n;
  231. }
  232. cc.Class({
  233. extends: cc.Component,
  234. properties: {
  235. scrollView: cc.ScrollView,
  236. bounceBottomCallBack: null,
  237. bounceTopCallBack: null,
  238. scrollEndedCallBack: null,
  239. scrollingCallBack: null,
  240. scrollToBottomCallBack: null,
  241. scrollToTopCallBack: null,
  242. updateItemDataCallBack: null,
  243. isToMoveBottom: !1,
  244. spacing: 0
  245. },
  246. start: function() {},
  247. setDataSet: function(t, e, i) {
  248. this.dataSet = t;
  249. this.parentJs = e;
  250. this.item = i;
  251. },
  252. updateDataSet: function(t, e) {
  253. var i = this;
  254. this.dataSet = t;
  255. this.content.height = this.dataSet.length * (this.itemHeight + this.spacing) + this.spacing;
  256. this.content.y < -Math.ceil(this.content.parent.height / 2) - this.itemHeight ? this.content.y = this.content.y - (this.itemHeight + this.spacing) : this.content.y = -Math.ceil(this.content.parent.height / 2);
  257. this.lastStartIndex = -1;
  258. if (e) for (var n = this.content.children, o = 0; o < n.length; o++) o < this.dataSet.length ? this.getView(n[o], n[o]._tag) : n[o].destroy();
  259. this.scheduleOnce(function() {
  260. i.startUpdate = !0;
  261. }, .1);
  262. },
  263. initUi: function() {
  264. var t = this;
  265. this.content = this.scrollView.content;
  266. this.lastStartIndex = -1;
  267. this.canScrollToTop = !1;
  268. this.itemNodePool = new cc.NodePool();
  269. var e = this.itemNodePool.get() || cc.instantiate(this.item);
  270. this.itemHeight = e.height;
  271. this.itemsVisibleNumber = Math.ceil(this.content.parent.height / this.itemHeight);
  272. this.content.height = this.dataSet.length * (this.itemHeight + this.spacing) + this.spacing;
  273. this.scheduleOnce(function() {
  274. t.itemsVisibleNumber = Math.ceil(t.content.parent.height / t.itemHeight);
  275. t.content.height < t.node.height && (t.content.height = t.node.height + 2);
  276. this.content.y = -Math.ceil(this.content.parent.height / 2);
  277. t.startUpdate = !0;
  278. }, .05);
  279. },
  280. update: function() {
  281. if (this.startUpdate) {
  282. var t = this.checkNeedUpdate();
  283. t >= 0 && this.updateView(t);
  284. }
  285. },
  286. checkNeedUpdate: function() {
  287. var t = Math.abs(this.content.y) - Math.floor(this.content.parent.height / 2), e = Math.floor(t / (this.itemHeight + this.spacing));
  288. if (e < 0 && !this.canScrollToTop) {
  289. this.scrollView.scrollToBottom();
  290. this.canScrollToTop = !0;
  291. return e;
  292. }
  293. e > 0 && (this.canScrollToTop = !1);
  294. if (this.lastStartIndex != e) {
  295. this.lastStartIndex = e;
  296. return e;
  297. }
  298. return -1;
  299. },
  300. updateView: function(t) {
  301. var e = t, n = e + this.itemsVisibleNumber + 5, o = this.dataSet.length;
  302. if (!(e >= o)) {
  303. n > o && (n = o);
  304. for (var a = this.getRecycleItems(e - 3, n), l = 0; l < a.length; l++) this.itemNodePool.put(a[l]);
  305. for (var c, s = i(this.findUpdateIndex(e, n)); !(c = s()).done; ) {
  306. var r = c.value, h = this.getView(this.itemNodePool.get() || cc.instantiate(this.item), r);
  307. h && this.layoutVertical(h, r);
  308. }
  309. }
  310. },
  311. getRecycleItems: function(t, e) {
  312. for (var i = [], n = this.content.children, o = 0; o < n.length; o++) (n[o]._tag < t || n[o]._tag > e) && i.push(n[o]);
  313. return i;
  314. },
  315. findUpdateIndex: function(t, e) {
  316. for (var i = [], n = this.content.children, o = t; o < e; o++) {
  317. for (var a = !1, l = 0; l < n.length; l++) if (o == n[l]._tag) {
  318. a = !0;
  319. break;
  320. }
  321. a || i.push(o);
  322. }
  323. return i;
  324. },
  325. getView: function(t, e) {
  326. if (this.updateItemDataCallBack) {
  327. if (!this.dataSet[e]) {
  328. this.itemNodePool.put(t);
  329. return !1;
  330. }
  331. this.updateItemDataCallBack(t, this.dataSet[e], e);
  332. }
  333. return t;
  334. },
  335. layoutVertical: function(t, e) {
  336. this.content.addChild(t);
  337. t._tag = e;
  338. t.setPosition(0, t.height * (.5 + e) + this.spacing * (e + 1));
  339. },
  340. scrollviewEventCallback: function(t, e) {
  341. e == cc.ScrollView.EventType.BOUNCE_BOTTOM ? this.bounceBottomCallBack && this.bounceBottomCallBack() : e == cc.ScrollView.EventType.BOUNCE_TOP ? this.bounceTopCallBack && this.bounceTopCallBack() : e == cc.ScrollView.EventType.SCROLL_ENDED ? this.scrollEndedCallBack && this.scrollEndedCallBack() : e == cc.ScrollView.EventType.SCROLLING ? this.scrollingCallBack && this.scrollingCallBack() : e == cc.ScrollView.EventType.SCROLL_TO_BOTTOM ? this.scrollToBottomCallBack && this.scrollToBottomCallBack() : e == cc.ScrollView.EventType.SCROLL_TO_TOP && this.scrollToTopCallBack && this.scrollToTopCallBack();
  342. },
  343. getData: function() {
  344. return this.dataSet ? this.dataSet : [];
  345. },
  346. getPosition: function(t) {
  347. return this.itemHeight * (.5 + t) + this.spacing * (t + 1);
  348. }
  349. });
  350. cc._RF.pop();
  351. }, {} ],
  352. testScene: [ function(t, e) {
  353. "use strict";
  354. cc._RF.push(e, "5a644LL5BhBxbYixJay9S9H", "testScene");
  355. cc.Class({
  356. extends: cc.Component,
  357. properties: {},
  358. start: function() {},
  359. clickBack: function() {
  360. SceneMgr.loadScene("hallCommon", {
  361. scene: "game"
  362. });
  363. }
  364. });
  365. cc._RF.pop();
  366. }, {} ]
  367. }, {}, [ "UserListView", "listViewDownToTopJs", "testScene" ]);