Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MenuScroller-1.3.2

added autofocus on active element
fixed not scrolling when started with mouse over
new calculation of scrolling speed
changed size of active element from 50% to 75% of hover size
spacing value is used literally (instated od multiplying by 2)
fixed other minor glitches
  • Loading branch information...
commit 46b5c882dbadb161bd3e0038270c8f952e7eb3e4 1 parent 0db87ab
@mstandio authored
View
2  ant/config/compiled_files.txt
@@ -53,7 +53,7 @@ LinkOpener.as = src/com/panozona/modules/linkopener/LinkOpener.as
LinkOpener.swf = bin/modules/linkopener/LinkOpener-1.1.swf
MenuScroller.as = src/com/panozona/modules/menuscroller/MenuScroller.as
-MenuScroller.swf = bin/modules/menuscroller/MenuScroller-1.3.1.swf
+MenuScroller.swf = bin/modules/menuscroller/MenuScroller-1.3.2.swf
MouseCursor.as = src/com/panozona/modules/mousecursor/MouseCursor.as
MouseCursor.swf = bin/modules/mousecursor/MouseCursor-1.2.swf
View
2  bin/_examples/settings/00_demo/01_demo.xml
@@ -67,7 +67,7 @@
<style id="buttonBar" content="bubblePadding:3,fontSize:12,borderSize:2"/>
</styles>
</InfoBubble>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<window open="false" onOpen="menuScrollerOpened" onClose="menuScrollerClosed" openTween="time:0.5" closeTween="time:0.5"/>
<close path="~media/images/buttons/dark_left_close.png" align="vertical:middle" move="horizontal:60"/>
<groups>
View
2  bin/_examples/settings/00_demo/05_imagebutton_menuscroller.xml
@@ -10,7 +10,7 @@
<panorama id="checkerYellow" path="~panos/dz_checker_yellow/checker_yellow_f.xml"/>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<window onOpen="onMenuOpen" onClose="onMenuClose" openTween="time:0.5" closeTween="time:0.5"/>
<close path="~media/images/buttons/dark_left_close.png" align="vertical:middle" move="horizontal:60"/>
<scroller overTween="transition:Linear.easeNone,time:0.5"/>
View
2  bin/_examples/settings/05_modules/menuscroller/01_basic.xml
@@ -15,7 +15,7 @@
<panorama id="checkerYellow" path="~panos/dz_checker_yellow/checker_yellow_f.xml"/>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<groups>
<group id="g1">
<element target="checkerBlue" path="~media/images/thumbs/checker_blue.jpg"/>
View
2  bin/_examples/settings/05_modules/menuscroller/02_open.xml
@@ -18,7 +18,7 @@
</panorama>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<window open="false" onOpen="printOpen" onClose="printClose"/>
<scroller style="color:#FFFFFF,alpha:0.75"/>
<groups>
View
2  bin/_examples/settings/05_modules/menuscroller/03_position.xml
@@ -23,7 +23,7 @@
</panorama>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<window transition="type:slideDown" align="horizontal:center" maxSize="width:2000,height:200" margin="left:50,right:50,top:50,bottom:50"/>
<close move="horizontal:10,vertical:-10" path="~media/images/misc/close.png"/>
<groups>
View
2  bin/_examples/settings/05_modules/menuscroller/04_manygroups.xml
@@ -20,7 +20,7 @@
</panorama>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<window transition="type:slideDown" align="horizontal:center,vertical:top" maxSize="width:600,height:200" margin="left:50,right:50,top:0,bottom:50"/>
<close move="horizontal:10,vertical:-10" path="~media/images/misc/close.png"/>
<groups>
View
2  bin/_examples/settings/05_modules/menuscroller/05_mouse.xml
@@ -13,7 +13,7 @@
<panorama id="checkerBlue" path="~panos/dz_checker_blue/checker_blue_f.xml"/>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<groups>
<group id="g1">
<element target="checkerBlue" path="~media/images/thumbs/checker_blue.jpg" mouse="onOver:blueOnOver,onOut:blueOnOut"/>
View
2  bin/_examples/settings/05_modules/menuscroller/06_extraelement.xml
@@ -14,7 +14,7 @@
</panorama>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<groups>
<group id="g1">
<extraElement id="logo" action="withdrawThenShowLogo" path="~media/images/misc/panozona_logo.png"/>
View
2  bin/_examples/settings/05_modules/menuscroller/07_setactive.xml
@@ -14,7 +14,7 @@
</panorama>
</panoramas>
<modules>
- <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.1.swf">
+ <MenuScroller path="~modules/menuscroller/MenuScroller-1.3.2.swf">
<groups>
<group id="g1">
<extraElement id="logo" action="printHelloLogo" path="~media/images/misc/panozona_logo.png"/>
View
16 src/com/panozona/modules/menuscroller/controller/ElementController.as
@@ -102,6 +102,12 @@ package com.panozona.modules.menuscroller.controller {
_elementView.elementData.addEventListener(ElementEvent.CHANGED_MOUSE_OVER, handleMouseOverChange, false, 0, true);
recaluclateSize();
+
+ if (_elementView.elementData.rawElement is Element && (_elementView.elementData.rawElement as Element).target
+ == _module.saladoPlayer.manager.currentPanoramaData.id) {
+ _elementView.elementData.isActive = true;
+ }
+
_elementView.elementData.isLoaded = true;
}
@@ -152,11 +158,11 @@ package com.panozona.modules.menuscroller.controller {
var scroller:Scroller = _elementView.menuScrollerData.scrollerData.scroller;
if (_elementView.elementData.isActive) {
Tweener.addTween(_elementView.content, {
- scaleX: plainScale * ((hoverScale - 1)/2 + 1),
- scaleY: plainScale * ((hoverScale - 1)/2 + 1),
- x: -_elementView.elementData.plainSize.width * ((hoverScale - 1)/2 + 1) * 0.5,
- y: -_elementView.elementData.plainSize.height * ((hoverScale - 1)/2 + 1) * 0.5,
- time: useTime ? scroller.outTween.time * 0.5 : 0,
+ scaleX: plainScale * ((hoverScale - 1) * 0.75 + 1),
+ scaleY: plainScale * ((hoverScale - 1) * 0.75 + 1),
+ x: -_elementView.elementData.plainSize.width * ((hoverScale - 1) * 0.75 + 1) * 0.5,
+ y: -_elementView.elementData.plainSize.height * ((hoverScale - 1) * 0.75 + 1) * 0.5,
+ time: useTime ? scroller.outTween.time * 0.25 : 0,
transition: scroller.outTween.transition
});
} else {
View
121 src/com/panozona/modules/menuscroller/controller/ScrollerController.as
@@ -40,6 +40,7 @@ package com.panozona.modules.menuscroller.controller{
private var elementsView:Vector.<ElementView>;
private var difference:Number;
+ private var focusPoint:Number;
public function ScrollerController(scrollerView:ScrollerView, module:Module){
_scrollerView = scrollerView;
@@ -49,7 +50,6 @@ package com.panozona.modules.menuscroller.controller{
elementsView = new Vector.<ElementView>();
_scrollerView.menuScrollerData.scrollerData.addEventListener(ScrollerEvent.CHANGED_CURRENT_GROUP_ID, handleCurrentGroupIdChange, false, 0, true);
- _scrollerView.menuScrollerData.scrollerData.addEventListener(ScrollerEvent.CHANGED_TOTAL_SIZE, handleWindowSizeChange, false, 0, true);
_scrollerView.menuScrollerData.scrollerData.addEventListener(ScrollerEvent.CHANGED_MOUSE_OVER, handleMouseOverChange, false, 0, true);
_scrollerView.menuScrollerData.windowData.addEventListener(WindowEvent.CHANGED_CURRENT_SIZE, handleWindowSizeChange, false, 0, true);
@@ -93,9 +93,7 @@ package com.panozona.modules.menuscroller.controller{
for each (var rawElement:RawElement in currentGroup.getAllChildren()) {
elementData = new ElementData(rawElement);
elementData.addEventListener(ElementEvent.CHANGED_IS_LOADED, onElementLoaded, false, 0, true);
- if (elementData.rawElement is Element && (elementData.rawElement as Element).target == _module.saladoPlayer.manager.currentPanoramaData.id) {
- elementData.isActive = true;
- }
+ elementData.addEventListener(ElementEvent.CHANGED_IS_ACTIVE, onElementActive, false, 0, true);
elementView = new ElementView(_scrollerView.menuScrollerData, elementData);
_scrollerView.elementsContainer.addChild(elementView);
elementController = new ElementController(elementView, _module);
@@ -125,15 +123,6 @@ package com.panozona.modules.menuscroller.controller{
_scrollerView.menuScrollerData.windowData.currentSize.height);
_scrollerView.elementsContainerMask.graphics.endFill();
- // data for container position
- if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
- difference = _scrollerView.menuScrollerData.scrollerData.totalSize -
- _scrollerView.menuScrollerData.windowData.currentSize.height;
- } else {
- difference = _scrollerView.menuScrollerData.scrollerData.totalSize -
- _scrollerView.menuScrollerData.windowData.currentSize.width;
- }
-
// place container
if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
_scrollerView.elementsContainer.x = (_scrollerView.menuScrollerData.windowData.currentSize.width -
@@ -150,7 +139,6 @@ package com.panozona.modules.menuscroller.controller{
_scrollerView.elementsContainer.y = (_scrollerView.menuScrollerData.windowData.currentSize.height -
_scrollerView.menuScrollerData.scrollerData.sizeLimit) * 0.5;
if (_scrollerView.menuScrollerData.windowData.currentSize.width > _scrollerView.menuScrollerData.scrollerData.totalSize) {
-
_scrollerView.elementsContainer.x = (_scrollerView.menuScrollerData.windowData.currentSize.width -
_scrollerView.menuScrollerData.scrollerData.totalSize) * 0.5;
} else if (_scrollerView.elementsContainer.x + _scrollerView.menuScrollerData.scrollerData.totalSize < _scrollerView.menuScrollerData.windowData.currentSize.width) {
@@ -158,66 +146,110 @@ package com.panozona.modules.menuscroller.controller{
} else if (_scrollerView.elementsContainer.x > 0) {
_scrollerView.elementsContainer.x = 0;
}
+ trace(_scrollerView.menuScrollerData.scrollerData.totalSize);
}
+ onEnterFrame();
}
private function onElementLoaded(e:Event = null):void {
- recalulateTotalSize();
+ handleWindowSizeChange();
+ }
+
+ private function onElementActive(e:Event = null):void {
+ handleWindowSizeChange();
}
private function recalulateTotalSize():void {
+ focusPoint = NaN;
if (elementsView.length == 0) {
return;
}
- var counter:Number = _scrollerView.menuScrollerData.scrollerData.scroller.spacing * 3;
+ var spacingStart:Number = 0;
+ var spacingTmp:Number = _scrollerView.menuScrollerData.scrollerData.scroller.spacing;
if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
- counter += (elementsView[0].elementData.hoverSize.height
+ spacingTmp += (elementsView[0].elementData.hoverSize.height
- elementsView[0].elementData.plainSize.height) * 0.5;
+ spacingStart = spacingTmp + elementsView[0].elementData.plainSize.height * 0.5;
} else {
- counter += (elementsView[0].elementData.hoverSize.width
+ spacingTmp += (elementsView[0].elementData.hoverSize.width
- elementsView[0].elementData.plainSize.width) * 0.5;
+ spacingStart = spacingTmp + elementsView[0].elementData.plainSize.width * 0.5;
}
+ var counter:Number = spacingTmp;
for each(var elementView:ElementView in elementsView) {
if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
elementView.x = 0;
elementView.y = counter;
counter += elementView.elementData.plainSize.height;
+ if (elementView.elementData.isActive) {
+ focusPoint = elementView.y + elementView.elementData.plainSize.height * 0.5;
+ }
} else {
elementView.x = counter;
elementView.y = 0;
- counter += elementView.elementData.plainSize.width
+ counter += elementView.elementData.plainSize.width;
+ if (elementView.elementData.isActive) {
+ focusPoint = elementView.x + elementView.elementData.plainSize.width * 0.5;
+ }
}
- counter += _scrollerView.menuScrollerData.scrollerData.scroller.spacing * 2;
+ counter += _scrollerView.menuScrollerData.scrollerData.scroller.spacing;
}
- counter += _scrollerView.menuScrollerData.scrollerData.scroller.spacing;
+ counter -= _scrollerView.menuScrollerData.scrollerData.scroller.spacing;
+
+ var spacingEnd:Number = 0;
+ spacingTmp = _scrollerView.menuScrollerData.scrollerData.scroller.spacing;
if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
- counter += (elementsView[elementsView.length - 1].elementData.hoverSize.height
+ spacingTmp += (elementsView[elementsView.length - 1].elementData.hoverSize.height
- elementsView[elementsView.length - 1].elementData.plainSize.height) * 0.5;
+ spacingEnd = spacingTmp + elementsView[elementsView.length - 1].elementData.plainSize.height * 0.5;
}else {
- counter += (elementsView[elementsView.length - 1].elementData.hoverSize.width
+ spacingTmp += (elementsView[elementsView.length - 1].elementData.hoverSize.width
- elementsView[elementsView.length - 1].elementData.plainSize.width) * 0.5;
+ spacingEnd = spacingTmp + elementsView[elementsView.length - 1].elementData.plainSize.width * 0.5;
}
+ counter += spacingTmp;
_scrollerView.menuScrollerData.scrollerData.totalSize = counter;
+ if (!isNaN(focusPoint)) {
+ if (focusPoint > counter * 0.5) {
+ focusPoint += spacingEnd * (focusPoint - counter * 0.5) / ((counter - spacingEnd) - counter * 0.5);
+ }else {
+ focusPoint -= spacingStart * ((spacingStart - focusPoint) / (counter * 0.5 - spacingStart) + 1);
+ }
+ }
+ if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
+ difference = _scrollerView.menuScrollerData.scrollerData.totalSize -
+ _scrollerView.menuScrollerData.windowData.currentSize.height;
+ } else {
+ difference = _scrollerView.menuScrollerData.scrollerData.totalSize -
+ _scrollerView.menuScrollerData.windowData.currentSize.width;
+ }
}
- private function handleMouseOverChange(e:Event):void {
- if(_scrollerView.menuScrollerData.scrollerData.mouseOver && difference > 0){
+ private function handleMouseOverChange(e:Event = null):void {
+ if (_scrollerView.menuScrollerData.scrollerData.mouseOver) {
_module.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
- }else {
- _module.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
private function onEnterFrame(e:Event = null):void {
- var targetPosition:Number = NaN;
- var speed:Number = NaN;
- var shift:Number = NaN;
+ var speed:Number = _scrollerView.menuScrollerData.scrollerData.scroller.speed;
+ var targetPosition:Number = 0;
+ var shift:Number = 0;
if (_scrollerView.menuScrollerData.scrollerData.scrollsVertical) {
- speed = _scrollerView.menuScrollerData.windowData.currentSize.height * 0.1;
- targetPosition = -difference * _scrollerView.mouseY /
- _scrollerView.menuScrollerData.windowData.currentSize.height;
- shift = speed * Math.abs(targetPosition - _scrollerView.elementsContainer.y) / difference;
- if (Math.abs(targetPosition - _scrollerView.elementsContainer.y ) < 1) return;
+ if (_scrollerView.menuScrollerData.windowData.currentSize.height > _scrollerView.menuScrollerData.scrollerData.totalSize){
+ targetPosition = (_scrollerView.menuScrollerData.windowData.currentSize.height -
+ _scrollerView.menuScrollerData.scrollerData.totalSize) * 0.5;
+ }else if(_scrollerView.menuScrollerData.scrollerData.mouseOver){
+ targetPosition = -difference * _scrollerView.mouseY /
+ _scrollerView.menuScrollerData.windowData.currentSize.height;
+ }else if (!isNaN(focusPoint)){
+ targetPosition = -difference * focusPoint / _scrollerView.menuScrollerData.scrollerData.totalSize;
+ }
+ if (Math.abs(targetPosition - _scrollerView.elementsContainer.y) < 1 && !_scrollerView.menuScrollerData.scrollerData.mouseOver) {
+ _module.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ return;
+ }
+ shift = speed * Math.abs(targetPosition - _scrollerView.elementsContainer.y);
if (targetPosition < _scrollerView.elementsContainer.y) {
if (targetPosition > _scrollerView.elementsContainer.y - shift) {
_scrollerView.elementsContainer.y = targetPosition
@@ -232,11 +264,20 @@ package com.panozona.modules.menuscroller.controller{
}
}
} else {
- speed = _scrollerView.menuScrollerData.windowData.currentSize.width * 0.1;
- targetPosition = -difference * _scrollerView.mouseX /
- _scrollerView.menuScrollerData.windowData.currentSize.width;
- shift = speed * Math.abs(targetPosition - _scrollerView.elementsContainer.x) / difference;
- if (Math.abs(targetPosition - _scrollerView.elementsContainer.x ) < 1) return;
+ if(_scrollerView.menuScrollerData.windowData.currentSize.width > _scrollerView.menuScrollerData.scrollerData.totalSize){
+ targetPosition = (_scrollerView.menuScrollerData.windowData.currentSize.width -
+ _scrollerView.menuScrollerData.scrollerData.totalSize) * 0.5;
+ }else if(_scrollerView.menuScrollerData.scrollerData.mouseOver){
+ targetPosition = -difference * _scrollerView.mouseX /
+ _scrollerView.menuScrollerData.windowData.currentSize.width;
+ }else if (!isNaN(focusPoint)) {
+ targetPosition = -difference * focusPoint / _scrollerView.menuScrollerData.scrollerData.totalSize;
+ }
+ if (Math.abs(targetPosition - _scrollerView.elementsContainer.x ) < 1 && !_scrollerView.menuScrollerData.scrollerData.mouseOver) {
+ _module.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ return;
+ }
+ shift = speed * Math.abs(targetPosition - _scrollerView.elementsContainer.x);
if (targetPosition < _scrollerView.elementsContainer.x) {
if (targetPosition > _scrollerView.elementsContainer.x - shift) {
_scrollerView.elementsContainer.x = targetPosition
View
3  src/com/panozona/modules/menuscroller/model/structure/Scroller.as
@@ -25,8 +25,9 @@ package com.panozona.modules.menuscroller.model.structure {
public const style:Style = new Style();
- public var spacing:Number = 20;
+ public var spacing:Number = 40;
public var padding:Number = 20;
+ public var speed:Number = 0.1;
public var overTween:Tween = new Tween(Equations.easeNone, 0.25);
public var outTween:Tween = new Tween(Equations.easeNone, 0.25);
Please sign in to comment.
Something went wrong with that request. Please try again.