Konstantin Zakablukovsky 9 лет назад
Родитель
Сommit
91814de904
2 измененных файлов с 66 добавлено и 0 удалено
  1. 1 0
      include/nitro.hrl
  2. 65 0
      src/elements/element_animate.erl

+ 1 - 0
include/nitro.hrl

@@ -199,6 +199,7 @@
 
 % SVG
 -record(svg, {?ELEMENT_BASE(element_svg), version="1.1", baseProfile="full", xmlns="http://www.w3.org/2000/svg", xmlnsxlink="http://www.w3.org/1999/xlink", xmlnsev="http://www.w3.org/2001/xml-events", preserveAspectRatio, contentScriptType, contentStyleType, viewBox, externalResourcesRequired, ?SVG_CONDITIONAL_PROCESSING, ?SVG_CORE, ?SVG_DOCUMENT_EVENT, ?SVG_FILTER_PRIMITIVE, ?SVG_GRAPHICAL_EVENT, ?SVG_PRESENTATION, ?SVG_TRANSFERT_FUNCTION, ?SVG_XLINK}).
+-record(animate, {?ELEMENT_BASE(element_animate), externalResourcesRequired, ?SVG_ANIMATION_EVENT, ?SVG_ANIMATION_ATTRIBUT_TARGET, ?SVG_ANIMATION_TIMING, ?SVG_ANIMATION_VALUE, ?SVG_ANIMATION_ADDITION, ?SVG_CONDITIONAL_PROCESSING, ?SVG_CORE, ?SVG_XLINK}).
 
 % Extras
 -record(upload,         {?CTRL_BASE(element_upload), name, value}).

+ 65 - 0
src/elements/element_animate.erl

@@ -0,0 +1,65 @@
+-module(element_animate).
+-author('Konstantin Zakablukovsky').
+-include("nitro.hrl").
+-compile(export_all).
+-import(element_svg, [svg_conditional_processing/1, svg_core/1, svg_xlink/1]).
+
+render_element(Record) ->
+	wf_tags:emit_tag(<<"animate">>, nitro:render(Record#animate.body),
+	list:append([
+		[
+			{<<"id">>, Record#animate.id},
+			{<<"class">>, Record#animate.class},
+			{<<"style">>, Record#animate.style},
+			{<<"externalResourcesRequired">>, Record#animate.externalResourcesRequired}
+		],
+		svg_animation_event(Record),
+		svg_animation_attribut_target(Record),
+		svg_animation_timing(Record),
+		svg_animation_value(Record),
+		svg_animation_addition(Record),
+		svg_conditional_processing(Record),
+		svg_core(Record),
+		svg_xlink(Record),
+		Record#animate.data_fields,
+		Record#animate.aria_states
+	])).
+
+% Common SVG animate attributes
+svg_animation_event(Record) -> [
+	{<<"onbegin">>, Record#animate.onbegin},
+	{<<"onend">>, Record#animate.onend},
+	{<<"onload">>, Record#animate.onload},
+	{<<"onrepeat">>, Record#animate.onrepeat}
+].
+svg_animation_attribut_target(Record) -> [
+	{<<"attributeType">>, Record#animate.attributeType},
+	{<<"attributeName">>, Record#animate.attributeName}
+].
+svg_animation_timing(Record) -> [
+	{<<"begin">>, Record#animate.svgbegin},
+	{<<"dur">>, Record#animate.dur},
+	{<<"end">>, Record#animate.svgend},
+	{<<"min">>, Record#animate.min},
+	{<<"max">>, Record#animate.max},
+	{<<"restart">>, Record#animate.restart},
+	{<<"repeatCount">>, Record#animate.repeatCount},
+	{<<"repeatDur">>, Record#animate.repeatDur},
+	{<<"fill">>, Record#animate.fill}
+].
+svg_animation_value(Record) -> [
+	{<<"calcMode">>, Record#animate.calcMode},
+	{<<"values">>, Record#animate.values},
+	{<<"keyTimes">>, Record#animate.keyTimes},
+	{<<"keySplines">>, Record#animate.keySplines},
+	{<<"from">>, Record#animate.from},
+	{<<"to">>, Record#animate.to},
+	{<<"by">>, Record#animate.by},
+	{<<"autoReverse">>, Record#animate.autoReverse},
+	{<<"accelerate">>, Record#animate.accelerate},
+	{<<"decelerate">>, Record#animate.decelerate}
+].
+svg_animation_addition(Record) -> [
+	{<<"additive">>, Record#animate.additive},
+	{<<"accumulate">>, Record#animate.accumulate}
+].