js/hicBrowser.js
/**
     * Zoom and center on bins at given screen coordinates.  Supports double-click zoom, pinch zoom.
     * @param direction
     * @param centerPX  screen coordinate to center on
     * @param centerPY  screen coordinate to center on
     * @returns {Promise<void>}
     */
Zoom and center on bins at given screen coordinates.  Supports double-click zoom, pinch zoom.
@param direction
@param centerPX  screen coordinate to center on
@param centerPY  screen coordinate to center on
@returns {Promise}
Zoom and center on bins at given screen coordinates . Supports double - click zoom pinch zoom . @param direction @param centerPX screen coordinate to center on @param centerPY screen coordinate to center on @returns { Promise }
async zoomAndCenter(direction, centerPX, centerPY) {
        if (!this.dataset) return;
        if (this.dataset.isWholeGenome(this.state.chr1) && direction > 0) {
            const genomeCoordX = centerPX * this.dataset.wholeGenomeResolution / this.state.pixelSize;
            const genomeCoordY = centerPY * this.dataset.wholeGenomeResolution / this.state.pixelSize;
            const chrX = this.genome.getChromsosomeForCoordinate(genomeCoordX);
            const chrY = this.genome.getChromsosomeForCoordinate(genomeCoordY);
            this.setChromosomes(chrX.index, chrY.index);
        } else {
            const resolutions = this.getResolutions();
            const viewDimensions = this.contactMatrixView.getViewDimensions()
            const dx = centerPX === undefined ? 0 : centerPX - viewDimensions.width / 2
            const dy = centerPY === undefined ? 0 : centerPY - viewDimensions.height / 2
            this.state.x += (dx / this.state.pixelSize);
            this.state.y += (dy / this.state.pixelSize);
            if (this.resolutionLocked ||
                (direction > 0 && this.state.zoom === resolutions[resolutions.length - 1].index) ||
                (direction < 0 && this.state.zoom === resolutions[0].index)) {
                const minPS = await this.minPixelSize(this.state.chr1, this.state.chr2, this.state.zoom)
                const state = this.state;
                const newPixelSize = Math.max(Math.min(MAX_PIXEL_SIZE, state.pixelSize * (direction > 0 ? 2 : 0.5)), minPS);
                const shiftRatio = (newPixelSize - state.pixelSize) / newPixelSize;
                state.pixelSize = newPixelSize;
                state.x += shiftRatio * (viewDimensions.width / state.pixelSize);
                state.y += shiftRatio * (viewDimensions.height / state.pixelSize);
                this.clamp();
                let event = HICEvent("LocusChange", {
                    state: state,
                    resolutionChanged: false,
                    chrChanged: false
                })
                this.update(event);
            } else {
                let i;
                for (i = 0; i < resolutions.length; i++) {
                    if (this.state.zoom === resolutions[i].index) break;
                }
                if (i !== undefined) {
                    const newZoom = resolutions[i + direction].index;
                    this.setZoom(newZoom);
                }
            }
        }
    }
async zoomAndCenter ( direction , centerPX , centerPY ) { if ( ! this . dataset ) return ; if ( this . dataset . isWholeGenome ( this . state . chr1 ) && direction > 0 ) { const genomeCoordX = centerPX * this . dataset . wholeGenomeResolution / this . state . pixelSize ; const genomeCoordY = centerPY * this . dataset . wholeGenomeResolution / this . state . pixelSize ; const chrX = this . genome . getChromsosomeForCoordinate ( genomeCoordX ) ; const chrY = this . genome . getChromsosomeForCoordinate ( genomeCoordY ) ; this . setChromosomes ( chrX . index , chrY . index ) ; } else { const resolutions = this . getResolutions ( ) ; const viewDimensions = this . contactMatrixView . getViewDimensions ( ) const dx = centerPX === undefined ? 0 : centerPX - viewDimensions . width / 2 const dy = centerPY === undefined ? 0 : centerPY - viewDimensions . height / 2 this . state . x += ( dx / this . state . pixelSize ) ; this . state . y += ( dy / this . state . pixelSize ) ; if ( this . resolutionLocked || ( direction > 0 && this . state . zoom === resolutions [ resolutions . length - 1 ] . index ) || ( direction < 0 && this . state . zoom === resolutions [ 0 ] . index ) ) { const minPS = await this . minPixelSize ( this . state . chr1 , this . state . chr2 , this . state . zoom ) const state = this . state ; const newPixelSize = Math . max ( Math . min ( MAX_PIXEL_SIZE , state . pixelSize * ( direction > 0 ? 2 : 0.5 ) ) , minPS ) ; const shiftRatio = ( newPixelSize - state . pixelSize ) / newPixelSize ; state . pixelSize = newPixelSize ; state . x += shiftRatio * ( viewDimensions . width / state . pixelSize ) ; state . y += shiftRatio * ( viewDimensions . height / state . pixelSize ) ; this . clamp ( ) ; let event = HICEvent ( "LocusChange" , { state : state , resolutionChanged : false , chrChanged : false } ) this . update ( event ) ; } else { let i ; for ( i = 0 ; i < resolutions . length ; i ++ ) { if ( this . state . zoom === resolutions [ i ] . index ) break ; } if ( i !== undefined ) { const newZoom = resolutions [ i + direction ] . index ; this . setZoom ( newZoom ) ; } } } }
Zoom and center on bins at given screen coordinates.
Zoom and center on bins at given screen coordinates .
// jump from whole genome to chromosome //this.eventBus.post(event);