File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 12
12
border-radius : 20px ;
13
13
margin : 10px auto;
14
14
padding : 20px ;
15
+ min-height : 200px ;
15
16
}
16
17
17
18
# drop-area .highlight {
39
40
< body >
40
41
< progress id ="progress " value ="0 " max ="100 "> </ progress >
41
42
< div id ="drop-area ">
43
+
42
44
< pre >
43
45
{{range $href, $name := . }}
44
46
< a href ="{{$href}} "> {{$name}}</ a >
47
49
< input type ="file " id ="fileElem " multiple accept ="image/* " onchange ="handleFiles(this.files) ">
48
50
</ div >
49
51
< script >
52
+
53
+ var div = document . getElementById ( 'drop-area' ) ;
54
+ var canvas = document . createElement ( 'canvas' ) ;
55
+ var ctx = canvas . getContext ( '2d' ) ;
56
+ canvas . width = div . offsetWidth ;
57
+ canvas . height = div . offsetHeight ;
58
+ ctx . font = "40px Arial" ;
59
+ ctx . fillStyle = "rgba(128, 128, 128, 0.5)" ;
60
+ ctx . textAlign = "center" ;
61
+ ctx . textBaseline = "middle" ;
62
+ ctx . fillText ( "Drag & Drop a File" , div . offsetWidth / 2 , div . offsetHeight / 2 ) ;
63
+ div . style . position = "relative" ;
64
+ div . appendChild ( canvas ) ;
65
+ canvas . style . position = "absolute" ;
66
+ canvas . style . top = 0 ;
67
+ canvas . style . left = 0 ;
68
+ canvas . style . zIndex = - 1 ;
69
+ canvas . style . pointerEvents = "none" ;
70
+
71
+
72
+
50
73
let dropArea = document . getElementById ( "drop-area" )
51
74
52
75
; [ 'dragenter' , 'dragover' , 'dragleave' , 'drop' ] . forEach ( eventName => {
You can’t perform that action at this time.
0 commit comments