Permalink
Browse files

handle more scale and float point errors

  • Loading branch information...
felipevex committed Sep 15, 2017
1 parent b48bdb8 commit 0bf3791f85d523bedf4725da93abaa66c9124049
Showing with 24 additions and 5 deletions.
  1. +17 −0 helper/browser/BrowserHandler.hx
  2. +7 −5 priori/view/PriDisplay.hx
@@ -0,0 +1,17 @@
package helper.browser;
import priori.system.PriDevice;
import priori.system.PriDeviceBrowser;
class BrowserHandler {
public static var MIN_FLOAT_POINT:Float = getMinFloat();
private static function getMinFloat():Float {
return switch(PriDevice.browser()) {
case PriDeviceBrowser.CHROME | PriDeviceBrowser.WEBKIT | PriDeviceBrowser.OPERA | PriDeviceBrowser.SAFARI : 0.0001;
case _: 0.01;
}
}
}
View
@@ -1,5 +1,6 @@
package priori.view;
import helper.browser.BrowserHandler;
import helper.display.DisplayHelperIgnition;
import priori.geom.PriGeomPoint;
import priori.geom.PriGeomBox;
@@ -172,9 +173,10 @@ class PriDisplay extends PriEventDispatcher {
**/
public var scaleY(get, set):Float;
private var dh:DisplayHelper = DisplayHelperIgnition.getDisplayHerlper();
public function new() {
super();
@@ -325,15 +327,15 @@ class PriDisplay extends PriEventDispatcher {
private function get_widthScaled():Float return this.width*this.dh.scaleX;
private function set_widthScaled(value:Float):Float {
var thisWidth:Float = this.width;
if (thisWidth != 0) this.scaleX = value / thisWidth;
if (thisWidth != 0) this.scaleX = (value<0?0:value) / thisWidth;
return value;
}
private function get_heightScaled():Float return this.height*this.dh.scaleY;
private function set_heightScaled(value:Float):Float {
var thisHeight:Float = this.height;
if (thisHeight != 0) this.scaleY = value / thisHeight;
if (thisHeight != 0) this.scaleY = (value<0?0:value) / thisHeight;
return value;
}
@@ -433,14 +435,14 @@ class PriDisplay extends PriEventDispatcher {
private function get_scaleX():Float return this.dh.scaleX;
private function set_scaleX(value:Float):Float {
this.dh.scaleX = value == null ? 1 : value == 0 ? 0.0001 : value;
this.dh.scaleX = value == null ? 1 : value == 0 ? BrowserHandler.MIN_FLOAT_POINT : value;
DomHelper.apply2dTransformation(this.dh.jselement, this.dh.scaleX, this.dh.scaleY, this.dh.rotation, this.dh.anchorX, this.dh.anchorY);
return value;
}
private function get_scaleY():Float return this.dh.scaleY;
private function set_scaleY(value:Float):Float {
this.dh.scaleY = value == null ? 1 : value == 0 ? 0.0001 : value;
this.dh.scaleY = value == null ? 1 : value == 0 ? BrowserHandler.MIN_FLOAT_POINT : value;
DomHelper.apply2dTransformation(this.dh.jselement, this.dh.scaleX, this.dh.scaleY, this.dh.rotation, this.dh.anchorX, this.dh.anchorY);
return value;
}

0 comments on commit 0bf3791

Please sign in to comment.