Permalink
Browse files

ZoomSlider 1.3

scroller reacts to mouse wheel events
changed property scrollsVertically to scrollsHorizontally
  • Loading branch information...
1 parent 9f17d8a commit 2a271daad2eb27fc9ec49ae823e9df4affc54a8b @mstandio committed Apr 1, 2013
@@ -32,7 +32,7 @@ package com.panozona.modules.zoomslider{
private var zoomSliderData:ZoomSliderData;
public function ZoomSlider():void{
- super("ZoomSlider", "1.2", "http://openpano.org/links/saladoplayer/modules/zoomslider/");
+ super("ZoomSlider", "1.3", "http://openpano.org/links/saladoplayer/modules/zoomslider/");
moduleDescription.addFunctionDescription("setOpen", Boolean);
moduleDescription.addFunctionDescription("toggleOpen");
@@ -105,11 +105,11 @@ package com.panozona.modules.zoomslider.controller {
_sliderView.zoomSliderData.windowData.addEventListener(WindowEvent.CHANGED_CURRENT_SIZE, handleWindowSizeChange, false, 0, true);
var maxSize:Size = new Size(
- _sliderView.zoomSliderData.sliderData.slider.slidesVertical ? cellWidth : _sliderView.sliderData.slider.maxLength,
- _sliderView.zoomSliderData.sliderData.slider.slidesVertical ? _sliderView.sliderData.slider.maxLength : cellHeight);
+ _sliderView.zoomSliderData.sliderData.slider.slidesHorizontal ? _sliderView.sliderData.slider.maxLength : cellWidth,
+ _sliderView.zoomSliderData.sliderData.slider.slidesHorizontal ? cellHeight : _sliderView.sliderData.slider.maxLength);
var minSize:Size = new Size(
- _sliderView.zoomSliderData.sliderData.slider.slidesVertical ? cellWidth : _sliderView.sliderData.slider.minLength,
- _sliderView.zoomSliderData.sliderData.slider.slidesVertical ? _sliderView.sliderData.slider.minLength : cellHeight);
+ _sliderView.zoomSliderData.sliderData.slider.slidesHorizontal ? _sliderView.sliderData.slider.minLength : cellWidth,
+ _sliderView.zoomSliderData.sliderData.slider.slidesHorizontal ? cellHeight : _sliderView.sliderData.slider.minLength);
_sliderView.zoomSliderData.sliderData.setMinMaxSize(minSize, maxSize);
}
@@ -163,6 +163,21 @@ package com.panozona.modules.zoomslider.controller {
currentFov = _module.saladoPlayer.manager.fieldOfView;
translateValueToPosition();
}
+ if(!isNaN(_sliderView.sliderData.wheelDelta)){
+ if (_sliderView.sliderData.wheelDelta > 0) {
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_UP, false, true, 0, cameraKeyBindingsClass.OUT));
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, false, true, 0, cameraKeyBindingsClass.IN));
+ _sliderView.sliderData.wheelDelta -= 1;
+ }else if (_sliderView.sliderData.wheelDelta < 0) {
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_UP, false, true, 0, cameraKeyBindingsClass.IN));
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, false, true, 0, cameraKeyBindingsClass.OUT));
+ _sliderView.sliderData.wheelDelta += 1;
+ }else {
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_UP, false, true, 0, cameraKeyBindingsClass.OUT));
+ _module.stage.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_UP, false, true, 0, cameraKeyBindingsClass.IN));
+ _sliderView.sliderData.wheelDelta = NaN;
+ }
+ }
if (_sliderView.sliderData.maxFov != _module.saladoPlayer.manager.minimumFieldOfView) {
_sliderView.sliderData.maxFov = _module.saladoPlayer.manager.minimumFieldOfView // too lazy to do this properly
translateValueToPosition();
@@ -25,6 +25,7 @@ package com.panozona.modules.zoomslider.events{
public static const CHANGED_FOV_LIMIT:String = "changedFovLimit";
public static const CHANGED_MOUSE_DRAG:String = "changedMouseDrag";
public static const CHANGED_BAR_LEAD:String = "changedBarLead";
+ public static const CHANGED_WHEEL_DELTA:String = "changedWheelDelta";
public static const CHANGED_ZOOM:String = "changedZoom";
public static const CHANGED_SIZE_LIMIT:String = "changedSizeLimit";
@@ -36,6 +36,8 @@ package com.panozona.modules.zoomslider.model {
private var _mouseDrag:Boolean;
private var _barLead:Boolean;
+ private var _wheelDelta:Number;
+
private var _minSize:Size = new Size(1, 1);
private var _maxSize:Size = new Size(1, 1);
@@ -81,6 +83,13 @@ package com.panozona.modules.zoomslider.model {
dispatchEvent(new SliderEvent(SliderEvent.CHANGED_BAR_LEAD));
}
+ public function get wheelDelta():Number {return _wheelDelta;}
+ public function set wheelDelta(value:Number):void {
+ if (value == _wheelDelta) return;
+ _wheelDelta = value;
+ dispatchEvent(new SliderEvent(SliderEvent.CHANGED_WHEEL_DELTA));
+ }
+
public function get minSize():Size {return _minSize};
public function get maxSize():Size {return _maxSize};
public function setMinMaxSize(minSize:Size, maxSize:Size):void {
@@ -25,7 +25,7 @@ package com.panozona.modules.zoomslider.model.structure{
public var minLength:Number = 100;
public var maxLength:Number = 300;
- public var slidesVertical:Boolean = true;
+ public var slidesHorizontal:Boolean = false;
public var listenKeys:Boolean = false;
}
}
@@ -66,6 +66,7 @@ package com.panozona.modules.zoomslider.view {
bar.addEventListener(MouseEvent.MOUSE_DOWN, leadStart, false, 0, true);
bar.addEventListener(MouseEvent.MOUSE_UP, leadStop, false, 0, true);
bar.addEventListener(MouseEvent.ROLL_OUT, leadStop, false, 0, true);
+ addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel, false, 0, true);
pointer.addChild(new Bitmap(pointerBD));
pointer.addEventListener(MouseEvent.MOUSE_DOWN, dragStart, false, 0, true);
@@ -98,9 +99,9 @@ package com.panozona.modules.zoomslider.view {
}
public function draw():void {
- var length:Number = _zoomSliderData.sliderData.slider.slidesVertical
- ? _zoomSliderData.windowData.currentSize.height
- : _zoomSliderData.windowData.currentSize.width;
+ var length:Number = _zoomSliderData.sliderData.slider.slidesHorizontal
+ ? _zoomSliderData.windowData.currentSize.width
+ : _zoomSliderData.windowData.currentSize.height;
bar.graphics.clear();
bar.graphics.beginBitmapFill(barBD, null, true);
@@ -115,7 +116,7 @@ package com.panozona.modules.zoomslider.view {
zoomInButton.y = 0;
zoomOutButton.y = bar.y + length - zoomInPlainBD.height * 0.5 - zoomOutPlainBD.height;
- if (!_zoomSliderData.sliderData.slider.slidesVertical) {
+ if (_zoomSliderData.sliderData.slider.slidesHorizontal) {
x = length;
rotation = 90;
zoomInButton.y += zoomInButton.height;
@@ -174,5 +175,14 @@ package com.panozona.modules.zoomslider.view {
private function leadStop(e:Event):void {
_zoomSliderData.sliderData.barLead = false;
}
+
+ private function mouseWheel(e:Event):void {
+ if (isNaN(_zoomSliderData.sliderData.wheelDelta)
+ || _zoomSliderData.sliderData.wheelDelta * (e as MouseEvent).delta < 0) {
+ _zoomSliderData.sliderData.wheelDelta = (e as MouseEvent).delta;
+ }else {
+ _zoomSliderData.sliderData.wheelDelta += (e as MouseEvent).delta;
+ }
+ }
}
}

0 comments on commit 2a271da

Please sign in to comment.