Last active
December 16, 2015 01:09
-
-
Save tuki0918/5352524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------- | |
fire!!! count1 | |
-------------- | |
| page: 1 | |
-------------- | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
more... | |
-------------- | |
fire!!! count2 | |
-------------- | |
| page: 2 | |
-------------- | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
more... | |
-------------- | |
fire!!! count3 | |
-------------- | |
| page: 3 | |
-------------- | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
more... | |
-------------- | |
fire!!! count4 | |
-------------- | |
| page: 4 | |
-------------- | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
more... | |
-------------- | |
fire!!! count5 | |
-------------- | |
| page: 5 | |
-------------- | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
more... | |
-------------- | |
fire!!! count6 | |
-------------- | |
| page: 6 | |
-------------- | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
more... | |
-------------- | |
fire!!! count7 | |
-------------- | |
| page: 7 | |
-------------- | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
more... | |
-------------- | |
fire!!! count8 | |
-------------- | |
| page: 8 | |
-------------- | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
more... | |
-------------- | |
fire!!! count9 | |
-------------- | |
| page: 9 | |
-------------- | |
65 | |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | |
more... | |
-------------- | |
fire!!! count10 | |
-------------- | |
| page: 10 | |
-------------- | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
more... | |
-------------- | |
fire!!! count11 | |
-------------- | |
| page: 11 | |
-------------- | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
more... | |
-------------- | |
fire!!! count12 | |
-------------- | |
| page: 12 | |
-------------- | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | |
96 | |
more... | |
-------------- | |
fire!!! count13 | |
-------------- | |
| page: 13 | |
-------------- | |
97 | |
98 | |
99 | |
100 | |
-------------- | |
fire!!! count14 | |
-------------- | |
fire!!! count15 | |
-------------- | |
fire!!! count16 | |
-------------- | |
fire!!! count17 | |
-------------- | |
fire!!! count18 | |
-------------- | |
fire!!! count19 | |
-------------- | |
fire!!! count20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DynamicScroll | |
constructor: (@data, @rows)-> | |
@page = 1 | |
@lastIndex = 0 | |
@maxLength = data.length | |
hasNext: -> | |
return @lastIndex < @maxLength | |
next: -> | |
stat = @lastIndex | |
end = @rows * ( @page - 1 ) + @rows | |
console.log "--------------" | |
console.log "| page: #{@page}" | |
console.log "--------------" | |
for i in [stat...end] | |
if !@hasNext() | |
return | |
# action | |
console.log @data[i] | |
@lastIndex++ | |
if @hasNext | |
console.log "more..." | |
@page++ | |
return | |
data = [1..100] | |
dc = new DynamicScroll data, 8 | |
fireScroll = -> | |
if dc.hasNext() | |
dc.next() | |
# fireScroll() for [1..20] | |
for i in [1..20] | |
do (i)-> | |
setTimeout -> | |
console.log "--------------" | |
console.log "fire!!! count#{i}" | |
fireScroll() | |
, 1000 * i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DynamicScroll | |
constructor: (@data, @rows)-> | |
@page = 1 | |
@lastIndex = 0 | |
@maxLength = data.length | |
hasNext: -> | |
return @lastIndex < @maxLength | |
next: (callback)-> | |
stat = @lastIndex | |
end = @rows * ( @page - 1 ) + @rows | |
console.log "--------------" | |
console.log "| page: #{@page}" | |
console.log "--------------" | |
for i in [stat...end] | |
if !@hasNext() | |
return | |
callback @data[i] | |
@lastIndex++ | |
if @hasNext | |
console.log "more..." | |
@page++ | |
return | |
data = [1..100] | |
dc = new DynamicScroll data, 8 | |
fireScroll = -> | |
if dc.hasNext() | |
dc.next (data)-> | |
console.log data | |
# fireScroll() for [1..20] | |
for i in [1..20] | |
do (i)-> | |
setTimeout -> | |
console.log "--------------" | |
console.log "fire!!! count#{i}" | |
fireScroll() | |
, 1000 * i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DynamicScroll | |
constructor: (@data, @rows)-> | |
@page = 1 | |
@lastIndex = 0 | |
@maxLength = data.length | |
hasNext: -> | |
return @lastIndex < @maxLength | |
next: (callback)-> | |
stat = @lastIndex | |
end = @rows * ( @page - 1 ) + @rows | |
for i in [stat...end] | |
if !@hasNext() | |
return | |
callback @data[i] | |
@lastIndex++ | |
@page++ | |
return | |
data = [1..100] | |
dc = new DynamicScroll data, 8 | |
fireScroll = -> | |
if dc.hasNext() | |
dc.next (data)-> | |
console.log data | |
for i in [1..20] | |
do (i)-> | |
setTimeout -> | |
fireScroll() | |
, 1000 * i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment