@@ -2,7 +2,8 @@
2ElmRuntime.Render.Element = function() {
2ElmRuntime.Render.Element = function() {
3'use strict';
3'use strict';
5−var fromList = Elm.JavaScript({}).fromList
5+var fromList = Elm.JavaScript({}).fromList;
6+var eq = Elm.Native.Utils({}).eq;
7function newElement(elementType) {
8function newElement(elementType) {
8 var e = document.createElement(elementType);
9 var e = document.createElement(elementType);
@@ -41,7 +42,7 @@ function image(props, img) {
41 switch (img._0.ctor) {
42 switch (img._0.ctor) {
42 case 'Plain': return plainImage(img._3);
43 case 'Plain': return plainImage(img._3);
43 case 'Fitted': return fittedImage(props.width, props.height, img._3);
44 case 'Fitted': return fittedImage(props.width, props.height, img._3);
44− case 'Cropped': return croppedImage(img._0._0,props.width,props.height,img._3);
45+ case 'Cropped': return croppedImage(img,props.width,props.height,img._3);
@@ -80,7 +81,8 @@ function fittedImage(w, h, src) {
83−function croppedImage(pos, w, h, src) {
84+function croppedImage(elem, w, h, src) {
85+ var pos = elem._0._0;
84 var e = newElement('div');
86 var e = newElement('div');
85 e.style.position = "relative";
87 e.style.position = "relative";
86 e.style.overflow = "hidden";
88 e.style.overflow = "hidden";
@@ -89,11 +91,11 @@ function croppedImage(pos, w, h, src) {
89 img.onload = function() {
91 img.onload = function() {
90 img.style.position = 'absolute';
92 img.style.position = 'absolute';
91 img.style.margin = 'auto';
93 img.style.margin = 'auto';
92− var sw = dimensions.width / w, sh = dimensions.height / h;
94+ var sw = w / elem._1, sh = h / elem._2;
93− img.style.width = (this.width * sw) + 'px';
95+ img.style.width = ((this.width * sw)|0) + 'px';
94− img.style.height = (this.height * sh) + 'px';
96+ img.style.height = ((this.height * sh)|0) + 'px';
95− img.style.left = (- pos._0 * sw) + 'px';
97+ img.style.left = ((- pos._0 * sw)|0) + 'px';
96− img.style.top = (- pos._1 * sh) + 'px';
98+ img.style.top = ((- pos._1 * sh)|0) + 'px';
98 img.src = src;
100 img.src = src;
99 img.name = src;
101 img.name = src;
@@ -207,7 +209,7 @@ function update(node, curr, next) {
207 case "Image":
209 case "Image":
208 if (nextE._0.ctor === 'Plain') {
210 if (nextE._0.ctor === 'Plain') {
209 if (nextE._3 !== currE._3) node.src = nextE._3;
211 if (nextE._3 !== currE._3) node.src = nextE._3;
210− } else if (!Value.eq(nextE,currE) ||
212+ } else if (!eq(nextE,currE) ||
211 next.props.width !== curr.props.width ||
213 next.props.width !== curr.props.width ||
212 next.props.height !== curr.props.height) {
214 next.props.height !== curr.props.height) {
213 node.parentNode.replaceChild(render(next),node);
215 node.parentNode.replaceChild(render(next),node);
@@ -255,7 +257,7 @@ function update(node, curr, next) {
255 if (next._0 !== curr._0) node.parentNode.replaceChild(render(next),node);
257 if (next._0 !== curr._0) node.parentNode.replaceChild(render(next),node);
258− var props = next.props, currP = curr.props;
260+ var props = next.props, currP = curr.props, e = node;
259 if (props.width !== currP.width) e.style.width = (props.width |0) + 'px';
261 if (props.width !== currP.width) e.style.width = (props.width |0) + 'px';
260 if (props.height !== currP.height) e.style.height = (props.height|0) + 'px';
262 if (props.height !== currP.height) e.style.height = (props.height|0) + 'px';
261 if (props.opacity !== 1 && props.opacity !== currP.opacity) {
263 if (props.opacity !== 1 && props.opacity !== currP.opacity) {