File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
#![ cfg( feature = "wasm" ) ]
2
+ use std:: collections:: VecDeque ;
3
+
2
4
use yew:: prelude:: * ;
3
5
use yew:: virtual_dom:: VNode ;
4
6
@@ -10,7 +12,7 @@ pub enum Msg {
10
12
}
11
13
12
14
pub struct App {
13
- images : Vec < VNode > ,
15
+ images : VecDeque < VNode > ,
14
16
}
15
17
16
18
impl Component for App {
@@ -19,26 +21,28 @@ impl Component for App {
19
21
20
22
fn create ( _ctx : & Context < Self > ) -> Self {
21
23
Self {
22
- images : Vec :: default ( ) ,
24
+ images : VecDeque :: default ( ) ,
23
25
}
24
26
}
25
27
26
28
fn update ( & mut self , _ctx : & Context < Self > , msg : Self :: Message ) -> bool {
27
29
match msg {
28
30
Msg :: Loaded ( file) => {
29
- self . images . push ( html ! { <ImageComponent file={ file} /> } ) ;
31
+ self . images
32
+ . push_front ( html ! { <ImageComponent file={ file} /> } ) ;
30
33
}
31
34
}
32
35
true
33
36
}
34
37
35
38
fn view ( & self , ctx : & Context < Self > ) -> Html {
39
+ let images: Vec < VNode > = self . images . clone ( ) . into ( ) ;
36
40
html ! {
37
41
<div id="wrapper" >
38
42
<h1>{ "Process your CGA/EGAs" } </h1>
39
43
<FileInput accept="image/*,.bin,.cga,.ega" onload={ ctx. link( ) . callback( Msg :: Loaded ) } children={ None } />
40
44
<div id="preview-area" >
41
- { { self . images. clone ( ) } }
45
+ { { images } }
42
46
</div>
43
47
</div>
44
48
}
You can’t perform that action at this time.
0 commit comments