Skip to content

Commit adc3a1e

Browse files
committed
bugfixes
1 parent 7a9d399 commit adc3a1e

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/icon-font-compatible.coffee

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
#
12
# out: ../icon-font-compatible.js
23
i = require "./icon"
34
ifc =
5+
template: i.template
46
mixins: i.mixins
7+
data: ->
8+
style: null
9+
attached: ->
10+
@style = window.getComputedStyle(@$el)
511
props:
612
name: i.props.name
713
flip: i.props.flip
@@ -11,14 +17,11 @@ ifc =
1117
box: i.computed.box
1218
flipped: i.computed.flipped
1319
height: ->
14-
@style = window.getComputedStyle(@$el) unless @style
15-
return @style.getPropertyValue("font-size").replace("px","")
16-
width: ->
17-
if @height?
18-
@icon.w / @icon.h * @height
20+
if @style
21+
return parseFloat @style.getPropertyValue("font-size").replace("px","")
1922
return null
23+
width: -> @icon.w / @icon.h * @height
2024
marginTop: ->
21-
@style = window.getComputedStyle(@$el) unless @style
2225
height = parseInt @style.getPropertyValue("line-height").replace("px","")
2326
return (height-@height)/2+'px'
2427

src/icon.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ module.exports =
3535
hcenter:
3636
type: Boolean
3737
default: false
38-
38+
data: ->
39+
parent: null
40+
attached: ->
41+
@parent = @$el.parentElement
3942
computed:
4043
icon: ->
4144
tmp = @name.split("-")
@@ -59,8 +62,8 @@ module.exports =
5962
else
6063
return null
6164
marginTop: ->
62-
if @hcenter and @$el.parentElement?
63-
return (@$el.parentElement.clientHeight-@height)/2+'px'
65+
if @hcenter and @parent?
66+
return (@parent.clientHeight-@height)/2+'px'
6467
return null
6568
6669
</script>

0 commit comments

Comments
 (0)