src/hg/hgTracks/imageV2.c 1.6

1.6 2009/07/17 18:25:41 tdreszer
Limit portal to chromSize. Fix dragScroll in IE which choked on ondrag event.
Index: src/hg/hgTracks/imageV2.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/imageV2.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -B -U 4 -r1.5 -r1.6
--- src/hg/hgTracks/imageV2.c	10 Jul 2009 19:48:18 -0000	1.5
+++ src/hg/hgTracks/imageV2.c	17 Jul 2009 18:25:41 -0000	1.6
@@ -1,7 +1,9 @@
 /* imageV2 - API for creating the image V2 features. */
 #include "common.h"
 #include "hPrint.h"
+#include "chromInfo.h"
+#include "hdb.h"
 #include "hui.h"
 #include "jsHelper.h"
 #include "imageV2.h"
 
@@ -643,9 +645,22 @@
 *chromStart = imgBox->chromStart - (int)(positionWidth/imageMultiple);
 if( *chromStart < 0)
     *chromStart = 0;
 *chromEnd = *chromStart + positionWidth;
-// TODO: Bound by chrom length
+struct chromInfo *chrInfo = hGetChromInfo(imgBox->db,imgBox->chrom);
+if(chrInfo == NULL)
+    {
+    *chromStart = imgBox->chromStart;
+    *chromEnd   = imgBox->chromEnd;
+    return FALSE;
+    }
+if (*chromEnd > (int)(chrInfo->size))  // Bound by chrom length
+    {
+    *chromEnd = (int)(chrInfo->size);
+    *chromStart = *chromEnd - positionWidth;
+    if (*chromStart < 0)
+        *chromStart = 0;
+    }
 // TODO: Normalize to power of 10 boundary
 double growthOfImage = (*chromEnd - *chromStart)/(imgBox->portalEnd - imgBox->portalStart);
 *imgWidth = (imgBox->portalWidth * growthOfImage) + imgBox->sideLabelWidth;
 
@@ -1018,9 +1033,9 @@
     hPrintf(" class='sideLab'");
 else if(slice->type==isCenter)
     hPrintf(" class='centerLab'");
 else if(slice->type==isData && imgBox->showPortal)
-    hPrintf(" class='panImg'");
+    hPrintf(" class='panImg' ondrag='{return false;}'");
 //hPrintf(" title='[%s] width:%d  height: %d  offsetX: %d  offsetY: %d'",
 //        sliceTypeToString(slice->type),slice->width,slice->height,slice->offsetX,slice->offsetY);
 if(slice->title != NULL)
     hPrintf(" title='%s'",slice->title);           // Adds slice wide title