Interactive interface for browsing global, full-resolution satellite imagery
limiting rotation to 360 degree in polar views #1576
Benjamin3de2097e8108
diff --git a/web/js/map/wv.map.rotate.js b/web/js/map/wv.map.rotate.jsindex ec96b1a7f..4fc25c2ae 100644--- a/web/js/map/wv.map.rotate.js+++ b/web/js/map/wv.map.rotate.js@@ -2,8 +2,9 @@ var wv = wv || {};wv.map = wv.map || {};wv.map.rotate = wv.map.rotate || function(ui, models, map) {- console.log('whatt')- this.evt = wv.util.events();+ this.evts = wv.util.events();+ this.intervalId;+ var self = this;/** Draws Rotation Widget*@@ -14,7 +15,6 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {**/this.createRotationWidget = function(map) {- var self = this;var $map = $("#" + map.getTarget());var $left = $("<button></button>")@@ -37,35 +37,46 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {$left.append($lefticon); $right.append($righticon);$map.append($left).append($mid).append($right);- var intervalId, dur = 500;+ var dur = 500;+ var clickManager = function(el, rotation) {+ el.unbind('mousedown')+ self.rotate(rotation, dur, map);+ setTimeout(function() {+ el.bind('mousedown', function() {+ clickManager(el, rotation)+ })+ }, dur + 25);+ }//Set buttons to animate rotation by 18 degrees. use setInterval to repeat the rotation when mouse button is held$left.button({text: false- }).mousedown(function() {- self.rotate(10, dur, map);- intervalId = setInterval(function() {- self.rotate(10, dur, map);- }, dur);- }).mouseup(function() {- clearInterval(intervalId);+ }).bind('mousedown', function() {+ self.intervalId = setInterval(function() {+ self.rotate(10, dur, map);+ }, dur);+ clickManager($left, 10);++ })+ .mouseup(function() {+ clearInterval(self.intervalId);});$right.button({text: false- }).mousedown(function() {- self.rotate(-10, dur, map);- intervalId = setInterval(function() {+ }).bind('mousedown', function() {+ self.intervalId = setInterval(function() {self.rotate(-10, dur, map);}, dur);+ clickManager($right, -10);}).mouseup(function() {- clearInterval(intervalId);+ clearInterval(self.intervalId);});$mid.button({label: Number(models.map.rotation * (180/Math.PI)).toFixed()}).mousedown(function() { //reset rotation- clearInterval(intervalId); //stop repeating rotation on mobile+ clearInterval(self.intervalId); //stop repeating rotation on mobilemap.beforeRender(ol.animation.rotate({duration: 500,rotation: map.getView().getRotation()@@ -81,20 +92,20 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {this.updateRotation = function() {var deg, radians;radians = ui.selected.getView().getRotation();-+ models.map.rotation = radians;window.history.replaceState("", "@OFFICIAL_NAME@","?" + models.link.toQueryString());deg = ((radians) * (180.0 / Math.PI));if(Math.abs(deg) >= 360) {-- if(radians > 0) {- this.evt.trigger('rotate-left-max')+ clearInterval(self.intervalId);+ if(deg > 0) {+ self.evts.trigger('rotate-right-max');} else {- this.evt.trigger('rotate-right-max')- }- models.map.rotation = radians;+ self.evts.trigger('rotate-left-max');+ }+ } else {+ self.evts.trigger('remove-freeze');}-//Set reset button content and proper CSS styling to position it correctly$(".wv-map-reset-rotation").button("option", "label", Number(deg).toFixed() );@@ -108,7 +119,7 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {$(".wv-map-reset-rotation").find("span").attr("style","padding-left: 14px");};- this.rotate = function(amount, duration, map) {+ this.rotate = function( amount, duration, map) {map.beforeRender(ol.animation.rotate({duration: duration,rotation: map.getView().getRotation()@@ -116,5 +127,14 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {map.getView().rotate(map.getView().getRotation() - (Math.PI / amount));}+ this.freezeClick = function( className ) {+ $('.' + className).addClass('ui-button-click-prevent');+ }+ this.removeFreeze = function() {+ var freezeEl = $('.wv-map-zoom.ui-button-click-prevent');+ if(freezeEl) {+ freezeEl.removeClass('ui-button-click-prevent');+ }+ }}