-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Restore +/- zoom and double click zoom * Make zoom consistent across mouse wheels * Fix zoom in/out buttons to scale 2x * Fix centering * Fix js errors breaking the page * Fix slider for minimal/embed views * Fix slider zoom step count
- Loading branch information
1 parent
322f5e5
commit 8584556
Showing
9 changed files
with
206 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* @fileOverview Contains the class definition for an ZoomControls class. | ||
* @author <a href="mailto:[email protected]">Jeff Stys</a> | ||
* @author <a href="mailto:[email protected]">Keith Hughitt</a> | ||
* @author <a href="mailto:[email protected]">Daniel Garcia Briseno</a> | ||
*/ | ||
/*jslint browser: true, white: true, onevar: true, undef: true, nomen: false, | ||
eqeqeq: true, plusplus: true, bitwise: true, regexp: false, strict: true, | ||
newcap: true, immed: true, maxlen: 80, sub: true */ | ||
/*globals $, Class */ | ||
"use strict"; | ||
|
||
class ZoomControls { | ||
/** | ||
* @constructs | ||
* | ||
* Creates a new ZoomControl | ||
* @param {number} maxImageScale Maximum image scale. | ||
* @param {number} nLevels Number of zoom levels | ||
* @param {() => void} slideStart | ||
* @param {(percentage: number) => void} setZoomLevel | ||
*/ | ||
constructor(maxImageScale, nLevels, slideStart, setZoomLevel) { | ||
this._maxImageScale = maxImageScale; | ||
this.nLevels = nLevels | ||
this.slideStart = slideStart; | ||
this.setZoomLevel = setZoomLevel; | ||
|
||
this.zoomSlider = $('#zoomControlSlider'); | ||
$(document).bind("helioviewer-ready", this._initSlider.bind(this)); | ||
$(document).bind("update-viewport", this._updateSliderValue.bind(this)); | ||
} | ||
|
||
get _currentLevel() { | ||
return Math.log(helioviewer.getZoomedImageScale() / this._maxImageScale) / Math.log(0.5); | ||
} | ||
|
||
/** | ||
* Update the slider value | ||
*/ | ||
_updateSliderValue() { | ||
let currentValue = this.zoomSlider.slider("value"); | ||
// Only change the value if it is significantly different. | ||
// Otherwise the slider value is changed, which triggers a zoom update | ||
// which triggers a slider update, and we have an infinite loop. | ||
let dt = Math.abs(currentValue - this._currentLevel); | ||
if (dt > 0.01) { | ||
this.zoomSlider.slider("value", this._currentLevel); | ||
} | ||
} | ||
|
||
/** | ||
* @description Initializes zoom level slider | ||
*/ | ||
_initSlider() { | ||
// Initialize slider | ||
this.zoomSlider.slider({ | ||
start: this.slideStart, | ||
slide: this.onslide.bind(this), | ||
min: 0, | ||
max: this.nLevels, | ||
step: 1, | ||
orientation: 'vertical', | ||
value: this._currentLevel | ||
}); | ||
|
||
// Add tooltip | ||
let description = "Drag this handle up and down to zoom in and out of " + | ||
"the displayed image."; | ||
$("#zoomControlSlider > .ui-slider-handle").attr('title', description) | ||
.qtip(); | ||
} | ||
|
||
onslide(event, slider) { | ||
this.setZoomLevel(slider.value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.