Skip to content

Commit b190750

Browse files
committed
add a default bbox if none is available; add bbox in all preset so even progressbar is not visible, we still have bbox to use.
1 parent dd66ae2 commit b190750

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

dist/loading-bar.js

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-bar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/loading-bar.zip

-4.06 KB
Binary file not shown.

src/loading-bar.ls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ do ->
216216
box = that.split(' ').map(->+(it.trim!))
217217
box = {x: box.0, y: box.1, width: box.2, height: box.3}
218218
else box = group.1.getBBox!
219+
if !box or box.width ==0 or box.height == 0 => box = {x: 0, y: 0, width: 100, height: 100}
219220
d = (Math.max.apply(
220221
null, <[stroke-width stroke-trail-width fill-background-extrude]>.map(->config[it]))
221222
) * 1.5

src/presets.ls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export presets =
33
"type": 'stroke'
44
"path": 'M10 10L90 10'
55
"stroke": 'data:ldbar/res,gradient(0,1,#a551df,#fd51ad,#ff7f82,#ffb874,#ffeb90)'
6+
"bbox": "10 10 80 0"
67
energy:
78
"type": 'fill'
89
"path": 'M15 5L85 5A5 5 0 0 1 85 15L15 15A5 5 0 0 1 15 5'
@@ -11,6 +12,7 @@ export presets =
1112
"fill-dir": "ltr"
1213
"fill-background": \#444
1314
"fill-background-extrude": 1
15+
"bbox": "10 5 80 10"
1416
stripe:
1517
"type": 'fill'
1618
"path": 'M15 5L85 5A5 5 0 0 1 85 15L15 15A5 5 0 0 1 15 5'
@@ -19,20 +21,23 @@ export presets =
1921
"fill-dir": "ltr"
2022
"fill-background": \#ddd
2123
"fill-background-extrude": 1
24+
"bbox": "10 5 80 10"
2225
text:
2326
"type": 'fill'
2427
"img": """data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="70" height="20" viewBox="0 0 70 20"><text x="35" y="10" text-anchor="middle" dominant-baseline="central" font-family="arial">LOADING</text></svg>"""
2528
"fill-background-extrude": 1.3
2629
"pattern-size": 100
2730
"fill-dir": "ltr"
2831
"img-size": "70,20"
32+
"bbox": "0 0 70 20"
2933
line:
3034
"type": 'stroke'
3135
"path": 'M10 10L90 10'
3236
"stroke": \#25b
3337
"stroke-width": 3
3438
"stroke-trail": \#ddd
3539
"stroke-trail-width": 1
40+
"bbox": "10 10 80 0"
3641
fan:
3742
"type": 'stroke'
3843
"path": 'M10 90A40 40 0 0 1 90 90'
@@ -45,6 +50,7 @@ export presets =
4550
"stroke-width": \3
4651
"stroke-trail": \#ddd
4752
"stroke-trail-width": 0.5
53+
"bbox": "10 50 80 40"
4854
circle:
4955
"type": 'stroke'
5056
"path": 'M50 10A40 40 0 0 1 50 90A40 40 0 0 1 50 10'
@@ -57,6 +63,7 @@ export presets =
5763
"stroke-width": \3
5864
"stroke-trail": \#ddd
5965
"stroke-trail-width": 0.5
66+
"bbox": "10 10 80 80"
6067
bubble:
6168
"type": 'fill'
6269
"path": 'M50 10A40 40 0 0 1 50 90A40 40 0 0 1 50 10'
@@ -70,3 +77,4 @@ export presets =
7077
"stroke-width": \3
7178
"stroke-trail": \#ddd
7279
"stroke-trail-width": 0.5
80+
"bbox": "10 10 80 80"

0 commit comments

Comments
 (0)