@@ -2,7 +2,8 @@
22ElmRuntime.Render.Element = function() {
33'use strict';
44
5−var fromList = Elm.JavaScript({}).fromList
5+var fromList = Elm.JavaScript({}).fromList;
6+var eq = Elm.Native.Utils({}).eq;
67
78function newElement(elementType) {
89 var e = document.createElement(elementType);
@@ -41,7 +42,7 @@ function image(props, img) {
4142 switch (img._0.ctor) {
4243 case 'Plain': return plainImage(img._3);
4344 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);
4546 }
4647}
4748
@@ -80,7 +81,8 @@ function fittedImage(w, h, src) {
8081 return e;
8182}
8283
83−function croppedImage(pos, w, h, src) {
84+function croppedImage(elem, w, h, src) {
85+ var pos = elem._0._0;
8486 var e = newElement('div');
8587 e.style.position = "relative";
8688 e.style.overflow = "hidden";
@@ -89,11 +91,11 @@ function croppedImage(pos, w, h, src) {
8991 img.onload = function() {
9092 img.style.position = 'absolute';
9193 img.style.margin = 'auto';
92− var sw = dimensions.width / w, sh = dimensions.height / h;
93− img.style.width = (this.width * sw) + 'px';
94− img.style.height = (this.height * sh) + 'px';
95− img.style.left = (- pos._0 * sw) + 'px';
96− img.style.top = (- pos._1 * sh) + 'px';
94+ var sw = w / elem._1, sh = h / elem._2;
95+ img.style.width = ((this.width * sw)|0) + 'px';
96+ img.style.height = ((this.height * sh)|0) + 'px';
97+ img.style.left = ((- pos._0 * sw)|0) + 'px';
98+ img.style.top = ((- pos._1 * sh)|0) + 'px';
9799 };
98100 img.src = src;
99101 img.name = src;
@@ -207,7 +209,7 @@ function update(node, curr, next) {
207209 case "Image":
208210 if (nextE._0.ctor === 'Plain') {
209211 if (nextE._3 !== currE._3) node.src = nextE._3;
210− } else if (!Value.eq(nextE,currE) ||
212+ } else if (!eq(nextE,currE) ||
211213 next.props.width !== curr.props.width ||
212214 next.props.height !== curr.props.height) {
213215 node.parentNode.replaceChild(render(next),node);
@@ -255,7 +257,7 @@ function update(node, curr, next) {
255257 if (next._0 !== curr._0) node.parentNode.replaceChild(render(next),node);
256258 break;
257259 }
258− var props = next.props, currP = curr.props;
260+ var props = next.props, currP = curr.props, e = node;
259261 if (props.width !== currP.width) e.style.width = (props.width |0) + 'px';
260262 if (props.height !== currP.height) e.style.height = (props.height|0) + 'px';
261263 if (props.opacity !== 1 && props.opacity !== currP.opacity) {