@@ -50,9 +50,7 @@ function Mapbox(opts) {
5050var proto = Mapbox . prototype ;
5151
5252module . exports = function createMapbox ( opts ) {
53- var mapbox = new Mapbox ( opts ) ;
54-
55- return mapbox ;
53+ return new Mapbox ( opts ) ;
5654} ;
5755
5856proto . plot = function ( calcData , fullLayout , promises ) {
@@ -76,8 +74,7 @@ proto.plot = function(calcData, fullLayout, promises) {
7674 promise = new Promise ( function ( resolve , reject ) {
7775 self . createMap ( calcData , fullLayout , resolve , reject ) ;
7876 } ) ;
79- }
80- else {
77+ } else {
8178 promise = new Promise ( function ( resolve , reject ) {
8279 self . updateMap ( calcData , fullLayout , resolve , reject ) ;
8380 } ) ;
@@ -163,7 +160,6 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
163160 var bb = self . div . getBoundingClientRect ( ) ;
164161
165162 // some hackery to get Fx.hover to work
166-
167163 evt . clientX = evt . point . x + bb . left ;
168164 evt . clientY = evt . point . y + bb . top ;
169165
@@ -211,8 +207,8 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
211207} ;
212208
213209proto . updateMap = function ( calcData , fullLayout , resolve , reject ) {
214- var self = this ,
215- map = self . map ;
210+ var self = this ;
211+ var map = self . map ;
216212
217213 self . rejectOnError ( reject ) ;
218214
@@ -230,8 +226,7 @@ proto.updateMap = function(calcData, fullLayout, resolve, reject) {
230226 self . updateLayout ( fullLayout ) ;
231227 self . resolveOnRender ( resolve ) ;
232228 } ) ;
233- }
234- else {
229+ } else {
235230 self . updateData ( calcData ) ;
236231 self . updateLayout ( fullLayout ) ;
237232 self . resolveOnRender ( resolve ) ;
@@ -240,7 +235,6 @@ proto.updateMap = function(calcData, fullLayout, resolve, reject) {
240235
241236proto . updateData = function ( calcData ) {
242237 var traceHash = this . traceHash ;
243-
244238 var traceObj , trace , i , j ;
245239
246240 // update or create trace objects
@@ -250,8 +244,9 @@ proto.updateData = function(calcData) {
250244 trace = calcTrace [ 0 ] . trace ;
251245 traceObj = traceHash [ trace . uid ] ;
252246
253- if ( traceObj ) traceObj . update ( calcTrace ) ;
254- else if ( trace . _module ) {
247+ if ( traceObj ) {
248+ traceObj . update ( calcTrace ) ;
249+ } else if ( trace . _module ) {
255250 traceHash [ trace . uid ] = trace . _module . plot ( this , calcTrace ) ;
256251 }
257252 }
@@ -264,7 +259,6 @@ proto.updateData = function(calcData) {
264259
265260 for ( j = 0 ; j < calcData . length ; j ++ ) {
266261 trace = calcData [ j ] [ 0 ] . trace ;
267-
268262 if ( id === trace . uid ) continue id_loop;
269263 }
270264
@@ -319,19 +313,15 @@ proto.createFramework = function(fullLayout) {
319313 var self = this ;
320314
321315 var div = self . div = document . createElement ( 'div' ) ;
322-
323316 div . id = self . uid ;
324317 div . style . position = 'absolute' ;
325-
326318 self . container . appendChild ( div ) ;
327319
328320 // create mock x/y axes for hover routine
329-
330321 self . xaxis = {
331322 _id : 'x' ,
332323 c2p : function ( v ) { return self . project ( v ) . x ; }
333324 } ;
334-
335325 self . yaxis = {
336326 _id : 'y' ,
337327 c2p : function ( v ) { return self . project ( v ) . y ; }
@@ -398,13 +388,10 @@ proto.updateFx = function(fullLayout) {
398388} ;
399389
400390proto . updateFramework = function ( fullLayout ) {
401- var domain = fullLayout [ this . id ] . domain ,
402- size = fullLayout . _size ;
391+ var domain = fullLayout [ this . id ] . domain ;
392+ var size = fullLayout . _size ;
403393
404394 var style = this . div . style ;
405-
406- // TODO Is this correct? It seems to get the map zoom level wrong?
407-
408395 style . width = size . w * ( domain . x [ 1 ] - domain . x [ 0 ] ) + 'px' ;
409396 style . height = size . h * ( domain . y [ 1 ] - domain . y [ 0 ] ) + 'px' ;
410397 style . left = size . l + domain . x [ 0 ] * size . w + 'px' ;
@@ -418,10 +405,10 @@ proto.updateFramework = function(fullLayout) {
418405} ;
419406
420407proto . updateLayers = function ( ) {
421- var opts = this . opts ,
422- layers = opts . layers ,
423- layerList = this . layerList ,
424- i ;
408+ var opts = this . opts ;
409+ var layers = opts . layers ;
410+ var layerList = this . layerList ;
411+ var i ;
425412
426413 // if the layer arrays don't match,
427414 // don't try to be smart,
@@ -437,8 +424,7 @@ proto.updateLayers = function() {
437424 for ( i = 0 ; i < layers . length ; i ++ ) {
438425 layerList . push ( createMapboxLayer ( this , i , layers [ i ] ) ) ;
439426 }
440- }
441- else {
427+ } else {
442428 for ( i = 0 ; i < layers . length ; i ++ ) {
443429 layerList [ i ] . update ( layers [ i ] ) ;
444430 }
@@ -487,21 +473,19 @@ proto.getView = function() {
487473} ;
488474
489475function getStyleObj ( val ) {
490- var styleValues = layoutAttributes . style . values ,
491- styleDflt = layoutAttributes . style . dflt ,
492- styleObj = { } ;
476+ var styleValues = layoutAttributes . style . values ;
477+ var styleDflt = layoutAttributes . style . dflt ;
478+ var styleObj = { } ;
493479
494480 if ( Lib . isPlainObject ( val ) ) {
495481 styleObj . id = val . id ;
496482 styleObj . style = val ;
497- }
498- else if ( typeof val === 'string' ) {
483+ } else if ( typeof val === 'string' ) {
499484 styleObj . id = val ;
500485 styleObj . style = ( styleValues . indexOf ( val ) !== - 1 ) ?
501486 convertStyleVal ( val ) :
502487 val ;
503- }
504- else {
488+ } else {
505489 styleObj . id = styleDflt ;
506490 styleObj . style = convertStyleVal ( styleDflt ) ;
507491 }
0 commit comments