make Util modular

This commit is contained in:
Devin Howard 2016-09-22 15:32:08 +08:00
parent 7f83f86460
commit d97b5c2977

View file

@ -1,11 +1,4 @@
/* global Metamaps */ import Visualize from './Visualize'
/*
* Metamaps.Util.js
*
* Dependencies:
* - Metamaps.Visualize
*/
const Util = { const Util = {
// helper function to determine how many lines are needed // helper function to determine how many lines are needed
@ -45,8 +38,8 @@ const Util = {
return Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow((p2.y - p1.y), 2)) return Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow((p2.y - p1.y), 2))
}, },
coordsToPixels: function (coords) { coordsToPixels: function (coords) {
if (Metamaps.Visualize.mGraph) { if (Visualize.mGraph) {
var canvas = Metamaps.Visualize.mGraph.canvas, var canvas = Visualize.mGraph.canvas,
s = canvas.getSize(), s = canvas.getSize(),
p = canvas.getPos(), p = canvas.getPos(),
ox = canvas.translateOffsetX, ox = canvas.translateOffsetX,
@ -67,8 +60,8 @@ const Util = {
}, },
pixelsToCoords: function (pixels) { pixelsToCoords: function (pixels) {
var coords var coords
if (Metamaps.Visualize.mGraph) { if (Visualize.mGraph) {
var canvas = Metamaps.Visualize.mGraph.canvas, var canvas = Visualize.mGraph.canvas,
s = canvas.getSize(), s = canvas.getSize(),
p = canvas.getPos(), p = canvas.getPos(),
ox = canvas.translateOffsetX, ox = canvas.translateOffsetX,