esvg 4.2.3 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/esvg/railties.rb +1 -0
- data/lib/esvg/symbol.rb +24 -14
- data/lib/esvg/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1381c5860ef655f9a00182855cd1b3000a04ca60
|
4
|
+
data.tar.gz: a01013c3fcc860731af45ce62cf03b7e684f4150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db44e7974abca942acf1e1ef096c1d8ebabae7a2c61e28dba86fdf58082d563b005328924aecef3ffbfef954388ca1459198b960ace849e271423a7a4c90d6c7
|
7
|
+
data.tar.gz: 69d1a74e01b6d8c640a7828b51ab74ec383ac61f401aaab636ec7775fc509a8fbd8c4638d061f5f0139c0707ee7096d7fbc172df0afb15c74ec525f12f8991cf
|
data/lib/esvg/railties.rb
CHANGED
data/lib/esvg/symbol.rb
CHANGED
@@ -72,7 +72,7 @@ module Esvg
|
|
72
72
|
options[:style] += "color:#{options[:color]};#{options[:style]}"
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
svg_attr = {
|
76
76
|
class: [@config[:class], @config[:prefix]+"-"+@name, options[:class]].compact.join(' '),
|
77
77
|
viewBox: @size[:viewBox],
|
78
78
|
style: options[:style],
|
@@ -81,25 +81,35 @@ module Esvg
|
|
81
81
|
}
|
82
82
|
|
83
83
|
# If user doesn't pass a size or set scale: true
|
84
|
-
if
|
85
|
-
|
86
|
-
|
87
|
-
use_attr[:width] = @size[:width]
|
88
|
-
use_attr[:height] = @size[:height]
|
84
|
+
if options[:width].nil? && options[:height].nil? && !options[:scale]
|
85
|
+
svg_attr[:width] = width
|
86
|
+
svg_attr[:height] = height
|
89
87
|
else
|
90
|
-
|
91
88
|
# Add sizes (nil options will be stripped)
|
92
|
-
|
93
|
-
|
89
|
+
svg_attr[:width] = options[:width]
|
90
|
+
svg_attr[:height] = options[:height]
|
94
91
|
end
|
95
92
|
|
96
|
-
|
93
|
+
use_attr = {
|
94
|
+
height: options[:height],
|
95
|
+
width: options[:width],
|
96
|
+
scale: options[:scale],
|
97
|
+
}
|
98
|
+
|
99
|
+
%Q{<svg #{attributes(svg_attr)}>#{use_tag(use_attr)}#{title(options)}#{desc(options)}#{options[:content]||''}</svg>}
|
97
100
|
end
|
98
101
|
|
99
102
|
def use_tag(options={})
|
100
103
|
options["xlink:href"] = "##{@id}"
|
101
|
-
|
102
|
-
|
104
|
+
|
105
|
+
# If user doesn't pass a size or set scale: true
|
106
|
+
if options[:width].nil? && options[:height].nil? && options[:scale].nil?
|
107
|
+
options[:width] ||= width
|
108
|
+
options[:height] ||= height
|
109
|
+
end
|
110
|
+
|
111
|
+
options.delete(:scale)
|
112
|
+
|
103
113
|
%Q{<use #{attributes(options)}/>}
|
104
114
|
end
|
105
115
|
|
@@ -207,8 +217,8 @@ module Esvg
|
|
207
217
|
|
208
218
|
{
|
209
219
|
viewBox: viewbox,
|
210
|
-
width: coords[2].to_i - coords[0].to_i,
|
211
|
-
height: coords[3].to_i - coords[1].to_i
|
220
|
+
width: (coords[2].to_i - coords[0].to_i).abs,
|
221
|
+
height: (coords[3].to_i - coords[1].to_i).abs
|
212
222
|
}
|
213
223
|
else
|
214
224
|
{}
|
data/lib/esvg/version.rb
CHANGED